Пример #1
0
    public virtual void LookAt(Vector3 target, float speed)
    {
        if (mFSM.CurRule == Monster_Die.GetInstance())
        {
            return;
        }

        startRot = new Quaternion(transform.rotation.x,
                                  transform.rotation.y,
                                  transform.rotation.z,
                                  transform.rotation.w);
        targetRot = LookAtTarget(new Vector2(target.x, target.y));
        float a = Quaternion.Angle(startRot, targetRot);

        rotateto_totalTime = a / (speed + 0.1f);
        rotateto_Timer     = 0;
        //
        Animator animator = GetComponent <Animator>();

        if (animator != null)
        {
            animator.SetBool("attack", false);
        }
        //

        mFSM.SetState(Monster_RotateTo.GetInstance());
    }
Пример #2
0
    public virtual void MoveTo(Vector3 target, float speed)
    {
        if (mFSM.CurRule == Monster_Die.GetInstance())
        {
            return;
        }

        mFSM.SetState(Monster_MoveTo.GetInstance());

        if (ReverseMove == true)
        {
            target.x = -target.x;
        }

        //targetPos = new Vector3(2.5f,1.5f,0);
        startPos  = new Vector3(transform.position.x, transform.position.y, 0);
        targetPos = new Vector3(target.x, target.y, 0);
        float dis = Vector3.Magnitude(startPos - targetPos);

        moveto_totalTime = dis / (speed + 0.1f);

        if (AlwaysUp == false)
        {
            transform.rotation = LookAtTarget(targetPos);
        }
        //
        Animator animator = GetComponent <Animator>();

        if (animator != null)
        {
            animator.SetBool("attack", false);
        }
        //
    }
Пример #3
0
 // Ładowanie komponentów
 protected override void Awake()
 {
     base.Awake();
     speed   = 0.5F;
     MyLives = 1;
     die     = Resources.Load <Monster_Die>("Zombie_die");
 }
Пример #4
0
 public static Monster_Die GetInstance()
 {
     if (instance == null)
     {
         instance = new Monster_Die();
     }
     return(instance);
 }
Пример #5
0
    // Ładowanie komponentów
    protected override void Awake()
    {
        base.Awake();
        speed   = 0.5F;
        MyLives = 1;
        die     = Resources.Load <Monster_Die>("Shooter_die");
        ball    = Resources.Load <Ball>("Ball");

        shoot    = true;
        NextFire = Time.time + fireExpectation;
    }
Пример #6
0
    public void Die()
    {
        m_bAlreadyDie = true;

        mFSM.SetState(Monster_Die.GetInstance());

        //GameManager.getInstance().m_SECtrl.PlaySound(SoundType.Sound_KillMonster);

        Animator animator = GetComponent <Animator>();

        if (animator != null)
        {
            animator.SetBool("die", true);
        }
        //
        if (GetComponent <BoxCollider2D>() != null)
        {
            GetComponent <BoxCollider2D>().enabled = false;
        }

        GameManager.getInstance().AddGameScore(MonsterScore);
    }