Commit af0652dd authored by astatham's avatar astatham
Browse files

Added moving target, all other targets on that level are inactive if moving target is active

parent c27f9839
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1681885780994998}
m_IsPrefabAsset: 1
--- !u!1 &1681885780994998
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4746125468523812}
- component: {fileID: 212955272991404522}
m_Layer: 0
m_Name: platform
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4746125468523812
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1681885780994998}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.68, y: -1.51, z: -0.046875}
m_LocalScale: {x: 0.24, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &212955272991404522
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1681885780994998}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: abc7c8627cab5494da8e4bd5f24a5796, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5, y: 0.86}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
fileFormatVersion: 2
guid: a4fd084d2373173479c0c947fd66e9ca
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -20,7 +20,6 @@ GameObject:
m_Component:
- component: {fileID: 4016853487692816}
- component: {fileID: 212452611458889896}
- component: {fileID: 61701222493856726}
m_Layer: 0
m_Name: pole
m_TagString: Untagged
......@@ -41,31 +40,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
--- !u!61 &61701222493856726
BoxCollider2D:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1010547747629248}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 5, y: 0.86}
newSize: {x: 5, y: 0.86}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 5, y: 0.5}
m_EdgeRadius: 0
--- !u!212 &212452611458889896
SpriteRenderer:
m_ObjectHideFlags: 1
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovingTarget : MonoBehaviour {
public float posChangeSpeed, maxPos, minPos;
public static float currentPos = 8f;
public static float previousPos = 8f;
void Start()
{
previousPos = -9f;
}
// Update is called once per frame
void Update()
{
if (currentPos >= minPos && currentPos < maxPos && currentPos > previousPos)
{
gameObject.transform.position = new Vector3(currentPos, -3.65f, 0);
previousPos = currentPos;
currentPos += (posChangeSpeed * Time.deltaTime);
}
else if (currentPos <= maxPos && currentPos > minPos && currentPos < previousPos)
{
gameObject.transform.position = new Vector3(currentPos, -3.65f, 0);
previousPos = currentPos;
currentPos -= (posChangeSpeed * Time.deltaTime);
}
else if (currentPos > previousPos)
{
gameObject.transform.position = new Vector3(currentPos, -3.65f, 0);
previousPos = currentPos;
currentPos -= (posChangeSpeed * Time.deltaTime);
}
else if (currentPos < previousPos)
{
gameObject.transform.position = new Vector3(currentPos, -3.65f, 0);
previousPos = currentPos;
currentPos += (posChangeSpeed * Time.deltaTime);
}
}
}
fileFormatVersion: 2
guid: 1a8f5a68b95cfc0429f6f5a25d89152e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -12,22 +12,22 @@ public class Needle : MonoBehaviour {
void Update()
{
if (PieManager.pieCount > 0)
{
if (Input.GetKeyDown("space"))
{
finalAngle = currentAngle;
angleChangeSpeed = 0;
PowerBar.previousPos = -9f;
}
else if (!Input.GetKey("space"))
{
MoveNeedle();
if (PieManager.pieCount > 0)
{
if (Input.GetKeyDown("space"))
{
finalAngle = currentAngle;
angleChangeSpeed = 0;
PowerBar.previousPos = -9f;
}
else if (!Input.GetKey("space"))
{
MoveNeedle();
}
}
}
public void MoveNeedle()
public void MoveNeedle()
{
angleChangeSpeed = 50;
if (currentAngle >= minAngle && currentAngle < maxAngle && currentAngle > previousAngle)
......
......@@ -30,5 +30,12 @@ public class PieManager : MonoBehaviour {
} while (targets[n].transform.parent.gameObject.activeSelf == false);
targets[n].transform.parent.gameObject.SetActive(false);
}
targets[0].transform.parent.gameObject.SetActive(true);
if (targets[0].transform.gameObject.activeSelf == true)
{
targets[2].transform.parent.gameObject.SetActive(false);
targets[5].transform.parent.gameObject.SetActive(false);
targets[8].transform.parent.gameObject.SetActive(false);
}
}
}
......@@ -3,11 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
public class PieTarget : MonoBehaviour {
// Update is called once per frame
void Update () {
}
private void OnTriggerEnter2D(Collider2D collision)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment