void Start() { Vector3 ownerPos = GetOwnerObject().transform.position; float reachLength = 1000.0f; if (WeaponObject.GetComponent <SwordObject>() != null) { reachLength = WeaponObject.GetComponent <SwordObject> ().ReachLength; } Vector3 moveDestPos = ownerPos; moveDestPos.x += reachLength; iTween.ValueTo(gameObject, iTween.Hash( "from", 1f, "to", 0f, "time", 0.15f, "onupdate", "SetValue", "oncomplete", "EffectCompleted" )); // Vector3 moveDestPos = GameManager.Instance.swordReachMarker.transform.position; moveDestPos.x -= transform.localScale.x / 2.0f; // Debug.LogError ("@@@@@@@markerPos: " + GameManager.Instance.swordReachMarker.transform.position + ", scale: " + transform.localScale.x + ", distPos: " + moveDestPos); iTween.MoveTo(gameObject, iTween.Hash( "position", moveDestPos, "islocal", false, "time", 0.15f )); }
public void AtackOn() { AudioManager.AudioON(2); int Direction = PlayerManager.Player.Direction.Value; GameObject Weapon = PlayerManager.Player.Weapon; Vector3 PlayerPos = PlayerManager.Player.GameObject.transform.position; GameObject WeaponObject; Animator Animator; switch (Direction) { case 0: WeaponObject = GameManager.Instantiate(Weapon, new Vector3(PlayerPos.x + 20, PlayerPos.y - 32, 0), Quaternion.identity); WeaponObject.transform.Rotate(0, 0, 20); WeaponObject.transform.Find("Sword0").gameObject.SetActive(true); Animator = WeaponObject.GetComponent <Animator>(); Animator.SetInteger("Direction", 0); WeaponObject.GetComponent <WeaponObject>().SetUp(); break; case 1: WeaponObject = GameManager.Instantiate(Weapon, new Vector3(PlayerPos.x - 20, PlayerPos.y + 32, 0), Quaternion.identity); WeaponObject.transform.Rotate(0, 0, 20); WeaponObject.transform.Find("Sword1").gameObject.SetActive(true); Animator = WeaponObject.GetComponent <Animator>(); Animator.SetInteger("Direction", 1); WeaponObject.GetComponent <WeaponObject>().SetUp(); break; case 2: WeaponObject = GameManager.Instantiate(Weapon, new Vector3(PlayerPos.x + 20, PlayerPos.y + 20, 0), Quaternion.identity); WeaponObject.transform.Rotate(0, 0, 20); WeaponObject.transform.Find("Sword2").gameObject.SetActive(true); Animator = WeaponObject.GetComponent <Animator>(); Animator.SetInteger("Direction", 2); WeaponObject.GetComponent <WeaponObject>().SetUp(); break; case 3: WeaponObject = GameManager.Instantiate(Weapon, new Vector3(PlayerPos.x - 20, PlayerPos.y + 20, 0), Quaternion.identity); WeaponObject.transform.Rotate(0, 0, -20); WeaponObject.transform.Find("Sword3").gameObject.SetActive(true); Animator = WeaponObject.GetComponent <Animator>(); Animator.SetInteger("Direction", 3); WeaponObject.GetComponent <WeaponObject>().SetUp(); break; } }