Beispiel #1
0
        public override void BeAttacked(SceneGameObject attacker)
        {
            var my     = GetPosition();
            var other  = attacker.GetPosition();
            var offset = other - my;

            offset.Normalize();
            int yRotation = 0;

            if (offset.x > 0)
            {
                if (offset.y > 0 && offset.y > offset.x)
                {
                    yRotation = 270;
                }
                else if (offset.y < 0 && -offset.y > offset.x)
                {
                    yRotation = 90;
                }
            }
            else
            {
                if (offset.y > 0 && offset.y > -offset.x)
                {
                    yRotation = 270;
                }
                else if (offset.y < 0 && -offset.y > -offset.x)
                {
                    yRotation = 90;
                }
                else
                {
                    yRotation = 180;
                }
            }
            var original = m_GameObject.transform.localEulerAngles;
            var oldy     = original.y;

            original.y = yRotation;

            Debug.Log("BeAttacked:x=" + offset.x + ",y=" + offset.y + ",rotation=" + yRotation + ",oldy=" + oldy);
            m_GameObject.transform.localEulerAngles = original;

            m_IsAttack = true;
        }
Beispiel #2
0
 public virtual void BeAttacked(SceneGameObject attacker)
 {
 }
Beispiel #3
0
 public virtual void Attack(SceneGameObject target)
 {
     target.BeAttacked(this);
 }