private IEnumerator BurstFire() { float shortBurstDelay = 0f; if (notUsable == false) { shortBurstDelay = 0.5f; notUsable = true; } if (notUsable == true) { while (shortBurstDelay > 0f) { shortBurstDelay -= Time.deltaTime; yield return(null); } for (int i = 0; i < fireRate; i++) { //so i want the object to spawn infront of ship and move in the direction of the retical GameObject instance = Instantiate(missle, new Vector3(parentOfRetical.position.x, parentOfRetical.position.y - 5f, parentOfRetical.position.z + 10f), Quaternion.identity); MoveInDirection prop = instance.AddComponent <MoveInDirection>(); instance = null; prop.reticalInformation = parentObject.transform; prop.speed = 10f; prop = null; } } StopAllCoroutines(); }
private void move(MoveInDirection moveInDirection) { Vector3 currentPosition = transform.position; Vector3 latestPosition = new Vector3(); switch (moveInDirection) { case MoveInDirection.UP: currentPosition.y = currentPosition.y + .1f; break; case MoveInDirection.RIGHT: currentPosition.x = currentPosition.x + .1f; break; case MoveInDirection.DOWN: currentPosition.y = currentPosition.y - .1f; break; case MoveInDirection.LEFT: currentPosition.x = currentPosition.x - .1f; break; } transform.position = currentPosition; }
public void stopRotate90Animation() { isRotating = false; GetComponent <Animator> ().SetBool("Rotate90", false); switch (moveInDirection) { case MoveInDirection.UP: moveInDirection = MoveInDirection.RIGHT; break; case MoveInDirection.RIGHT: moveInDirection = MoveInDirection.DOWN; break; case MoveInDirection.DOWN: moveInDirection = MoveInDirection.LEFT; break; case MoveInDirection.LEFT: moveInDirection = MoveInDirection.UP; break; } }
private IEnumerator BurstFire() { float shortBurstDelay = 0f; if (notUsable == false) { shortBurstDelay = 0.5f; notUsable = true; } if (notUsable == true) { while (shortBurstDelay > 0f) { shortBurstDelay -= Time.deltaTime; yield return(null); } for (int i = 0; i < fireRate; i++) { GameObject instance = Instantiate(missle, new Vector3(transform.position.x, transform.position.y + 5f, transform.position.z), Quaternion.identity); MoveInDirection prop = instance.AddComponent <MoveInDirection>(); instance = null; prop.reticalInformation = ReticalPosition; prop.speed = 10f; prop = null; } } StopAllCoroutines(); }
public void move(int direction) { if (direction == 1) { moveInDirection = MoveInDirection.RIGHT; } else if (direction == 2) { moveInDirection = MoveInDirection.DOWN; } else if (direction == 3) { moveInDirection = MoveInDirection.UP; } else { moveInDirection = MoveInDirection.LEFT; } if (isRotating == false) { Vector3 currentPosition = transform.position; Vector3 latestPosition = new Vector3(); switch (moveInDirection) { case MoveInDirection.UP: currentPosition.y = currentPosition.y + .1f; break; case MoveInDirection.RIGHT: currentPosition.x = currentPosition.x + .1f; break; case MoveInDirection.DOWN: currentPosition.y = currentPosition.y - .1f; break; case MoveInDirection.LEFT: currentPosition.x = currentPosition.x - .1f; break; } transform.position = currentPosition; } }
public void stopRotate90Animation() { isRotating = false; GetComponent<Animator> ().SetBool("Rotate90",false); switch (moveInDirection) { case MoveInDirection.UP: moveInDirection = MoveInDirection.RIGHT; break; case MoveInDirection.RIGHT: moveInDirection = MoveInDirection.DOWN; break; case MoveInDirection.DOWN: moveInDirection = MoveInDirection.LEFT; break; case MoveInDirection.LEFT: moveInDirection = MoveInDirection.UP; break; } }
/// <summary> /// Given a root XML node parse all the children and /// instantiate a component on the appropriate object with the appropriate parameters /// </summary> /// <param name="root">XML node of type "ClickFireDirection"</param> public static void ParseFromXML(XmlNode root) { //http://www.csharp-examples.net/xml-nodes-by-name/ XmlNode targetNode = root.SelectSingleNode("target"); // find all node with target property; assumes only one Debug.Log("found target node: " + targetNode.InnerText); // assign component to GameObject in the environment that has matching name GameObject cO = GameObject.Find(targetNode.InnerText); // find target in the environment if (cO == null) { return; } cO.gameObject.AddComponent <MoveInDirection>(); // already know this component because of type MoveInDirection cref = cO.gameObject.GetComponent <MoveInDirection>(); // cache for efficiency // look up and parse each attribute needed for script cref.dir = (MoveDirection)Enum.Parse(typeof(MoveDirection), root.SelectSingleNode("moveDirection").InnerText); cref.moveRate = float.Parse(root.SelectSingleNode("moveSpeed").InnerText); }
private void move( MoveInDirection moveInDirection) { Vector3 currentPosition = transform.position; Vector3 latestPosition = new Vector3 (); switch (moveInDirection) { case MoveInDirection.UP: currentPosition.y = currentPosition.y + .1f; break; case MoveInDirection.RIGHT: currentPosition.x = currentPosition.x + .1f; break; case MoveInDirection.DOWN: currentPosition.y = currentPosition.y - .1f; break; case MoveInDirection.LEFT: currentPosition.x = currentPosition.x - .1f; break; } transform.position = currentPosition; }
public void move(int direction) { if (direction == 1) moveInDirection = MoveInDirection.RIGHT; else if (direction == 2) moveInDirection = MoveInDirection.DOWN; else if (direction == 3) moveInDirection = MoveInDirection.UP; else moveInDirection = MoveInDirection.LEFT; if (isRotating == false) { Vector3 currentPosition = transform.position; Vector3 latestPosition = new Vector3 (); switch (moveInDirection) { case MoveInDirection.UP: currentPosition.y = currentPosition.y + .1f; break; case MoveInDirection.RIGHT: currentPosition.x = currentPosition.x + .1f; break; case MoveInDirection.DOWN: currentPosition.y = currentPosition.y - .1f; break; case MoveInDirection.LEFT: currentPosition.x = currentPosition.x - .1f; break; } transform.position = currentPosition; } }
void Start() { moveInDirection = MoveInDirection.UP; }
void Awake() { sr = GetComponent <DirectionRandomizer>(); mover = GetComponent <MoveInDirection>(); }
private void Awake() { Mover = GetComponent <MoveInDirection>(); }