public void applyState() { Flag.Character.init(m_state); Flag.PhysicalBody.init(m_physical); if (Flag.Character.check(Flag.Character.FlagState.STATE_ATTACKING)) { string opponent = name.Equals("player") ? "enemy" : "player"; GameObject object_opponent = GameObject.Find(opponent); Races race_opponent = object_opponent.GetComponent <Races> (); //accelation Vector3 direction = object_opponent.transform.position - transform.position; //normal //Vector3 direction = Scene.init_position [(int)race_opponent.m_direction] - Scene.init_position [(int)m_direction]; float speed = 0; direction = normalize(direction, ref speed); if (Flag.PhysicalBody.check(Flag.PhysicalBody.FlagState.STATE_ENTER)) { direction = -direction; } transform.Translate(2 * speed * direction * Time.deltaTime / Flag.Button.m_button_time); if (checkInitPosition()) { transform.position = Scene.init_position [(int)m_direction]; Flag.Character.reset(Flag.Character.FlagState.STATE_ATTACKING); Flag.PhysicalBody.reset(Flag.PhysicalBody.FlagState.STATE_ENTER); } } else if (Flag.Character.check(Flag.Character.FlagState.STATE_DEFENSING)) { if (Flag.PhysicalBody.check(Flag.PhysicalBody.FlagState.STATE_ENTER)) { Flag.PhysicalBody.reset(Flag.PhysicalBody.FlagState.STATE_ENTER); } Debug.Log("Defensing"); } else if (Flag.Character.check(Flag.Character.FlagState.STATE_CHARGING)) { Debug.Log("Charging"); } m_state = Flag.Character.get(); m_physical = Flag.PhysicalBody.get(); }
public void applyState() { Flag.Character.init (m_state); Flag.PhysicalBody.init (m_physical); if (Flag.Character.check (Flag.Character.FlagState.STATE_ATTACKING)) { string opponent = name.Equals ("player") ? "enemy" : "player"; GameObject object_opponent = GameObject.Find (opponent); Races race_opponent = object_opponent.GetComponent<Races> (); //accelation Vector3 direction = object_opponent.transform.position - transform.position; //normal //Vector3 direction = Scene.init_position [(int)race_opponent.m_direction] - Scene.init_position [(int)m_direction]; float speed = 0; direction = normalize (direction, ref speed); if (Flag.PhysicalBody.check (Flag.PhysicalBody.FlagState.STATE_ENTER)) direction = -direction; transform.Translate (2 * speed * direction * Time.deltaTime / Flag.Button.m_button_time); if(checkInitPosition()){ transform.position = Scene.init_position [(int)m_direction]; Flag.Character.reset (Flag.Character.FlagState.STATE_ATTACKING); Flag.PhysicalBody.reset (Flag.PhysicalBody.FlagState.STATE_ENTER); } } else if (Flag.Character.check (Flag.Character.FlagState.STATE_DEFENSING)) { if(Flag.PhysicalBody.check (Flag.PhysicalBody.FlagState.STATE_ENTER)){ Flag.PhysicalBody.reset(Flag.PhysicalBody.FlagState.STATE_ENTER); } Debug.Log ("Defensing"); } else if (Flag.Character.check (Flag.Character.FlagState.STATE_CHARGING)) { Debug.Log ("Charging"); } m_state = Flag.Character.get (); m_physical = Flag.PhysicalBody.get (); }
void OnTriggerEnter2D(Collider2D other) { Flag.PhysicalBody.init (m_physical); Flag.PhysicalBody.set (Flag.PhysicalBody.FlagState.STATE_ENTER); m_physical = Flag.PhysicalBody.get (); }
public void init() { m_state = Flag.Character.FlagState.STATE_NOTHING; m_physical = Flag.PhysicalBody.FlagState.STATE_NOTHING; }
void OnTriggerEnter2D(Collider2D other) { Flag.PhysicalBody.init(m_physical); Flag.PhysicalBody.set(Flag.PhysicalBody.FlagState.STATE_ENTER); m_physical = Flag.PhysicalBody.get(); }