Exemple #1
0
    void HitRobot(Notification noti)
    {
        PlayerBulletManager.Bullets b = (PlayerBulletManager.Bullets)noti.data;

        if (b.Target.name.Equals(gameObject.name))
        {
            m_Brain.BeAttacked();
            HP = HP - b.harmful;
            NotificationCenter.DefaultCenter().PostNotification(this, "HitEnemyP", b.EndPosition);
            // Vector3 direction = transform.position - EnemyTarget.transform.position;
            // m_rigid.velocity = direction.normalized;
            if (HP <= 0 && !haddead)
            {
                m_animator.SetTrigger("Dead");
                m_agent.ResetPath();
                NotificationCenter.DefaultCenter().PostNotification(this, "RobotDead");
                if (FireParticle != null)
                {
                    NotificationCenter.DefaultCenter().PostNotification(this, "FastBulletNotFireP", FireParticle);
                }
                NotificationCenter.DefaultCenter().PostNotification(this, "DeadEnemyP", transform.position);
                GetComponent <BoxCollider>().enabled = false;
                DestroyObject(gameObject, 2);
                haddead = true;
            }
        }
    }
    public void Fight()
    {
        if (Vector3.Distance(Player.position, transform.position) < m_self.TransformationArea && Shooting)
        {
            Shootingtime += Time.deltaTime;

            if (Shootingtime <= Shootingmaxtime)
            {
                if (!m_animator.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
                {
                    m_animator.SetTrigger("Attack");
                    NotificationCenter.DefaultCenter().PostNotification(this, "FastBulletFireP", FireParticle);
                }

                waitingBullet += Time.deltaTime * Speed;
                if (waitingBullet >= 1)
                {
                    int bullets = (int)waitingBullet;
                    waitingBullet -= bullets;
                    //发出bullets发子弹
                    PlayerBulletManager.Bullets tempbullets = new PlayerBulletManager.Bullets();
                    tempbullets.StartPosition  = transform.position;
                    tempbullets.localdirection = transform.forward;
                    tempbullets.harmful        = harmful;
                    tempbullets.Bulletstype    = PlayerBulletManager.bulletstype.EnemyFast;
                    for (int i = 0; i < bullets; i++)
                    {
                        //Debug.Log("EnemyFast");

                        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
                        tempbullets.localdirection = transform.right;
                        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
                        tempbullets.localdirection = -transform.right;
                        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
                        tempbullets.localdirection = -transform.forward;
                        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
                    }
                }
            }
            else
            {
                Shooting     = false;
                Shootingtime = 0;
            }
        }
        else
        {
            Catridgetime += Time.deltaTime;
            if (!m_animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
            {
                m_animator.SetTrigger("Idle");
                NotificationCenter.DefaultCenter().PostNotification(this, "FastBulletNotFireP", FireParticle);
            }
            if (Catridgetime >= Catridge)
            {
                Shooting     = true;
                Catridgetime = 0;
            }
        }
    }
Exemple #3
0
    void SlowBulletBoomP(Notification noti)
    {
        PlayerBulletManager.Bullets b = (PlayerBulletManager.Bullets)noti.data;
        GameObject tmp = Instantiate(SlowBulletBoomParticles);

        tmp.transform.position = b.EndPosition;
    }
Exemple #4
0
 void Start()
 {
     m_Player    = GameObject.Find("SUNman");
     tempbullets = new PlayerBulletManager.Bullets();
     NotificationCenter.DefaultCenter().AddObserver(this, "Fighting");
     m_PDirector = GetComponent <PlayableDirector>();
     m_camera    = Camera.main.transform;
     NotificationCenter.DefaultCenter().AddObserver(this, "PlayerFightingAddAttack");
 }
Exemple #5
0
    override public void Shooting()
    {
        PlayerBulletManager.Bullets tempbullets = new PlayerBulletManager.Bullets();
        tempbullets.StartPosition  = transform.position;
        tempbullets.localdirection = EnemyTarget.position - transform.position;
        tempbullets.harmful        = harmful;
        tempbullets.Bulletstype    = PlayerBulletManager.bulletstype.EnemySlow;


        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
    }
    override public void Shooting()
    {
        parent_body.Shooting      = false;
        parent_body.Cartridgetime = 0;

        PlayerBulletManager.Bullets tempbullets = new PlayerBulletManager.Bullets();
        tempbullets.StartPosition  = transform.position;
        tempbullets.localdirection = transform.forward;
        tempbullets.harmful        = parent_body.harmful;
        tempbullets.Bulletstype    = PlayerBulletManager.bulletstype.EnemySlow;


        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
    }
Exemple #7
0
    void CalculatelNumberOfBullets()
    {
        waitingbullets += Time.deltaTime * ShootingSpeed;

        if (waitingbullets >= 1)
        {
            int bullets = (int)waitingbullets;
            waitingbullets -= bullets;
            if (BulletsInGun < bullets)
            {
                bullets = BulletsInGun;
                //弹夹打完了欸
                Shooting     = false;
                BulletsInGun = 0;
                Cartridging  = true;
            }
            else
            {
                Shooting      = true;
                Cartridgetime = 0;
                // Debug.Log(m_animator.GetCurrentAnimatorStateInfo(0).IsName("Shooting"));
                if (!m_animator.GetCurrentAnimatorStateInfo(0).IsName("Shooting"))
                {
                    m_animator.SetTrigger("Shooting");
                }
                if (m_animator.GetCurrentAnimatorStateInfo(0).IsName("Shooting"))
                {
                    if (FireParticle != null)
                    {
                        NotificationCenter.DefaultCenter().PostNotification(this, "FastBulletFireP", FireParticle);
                    }
                    BulletsInGun -= bullets;
                    //发出bullets发子弹
                    PlayerBulletManager.Bullets tempbullets = new PlayerBulletManager.Bullets();
                    tempbullets.StartPosition  = transform.position;
                    tempbullets.localdirection = transform.forward;
                    tempbullets.harmful        = harmful;
                    tempbullets.Bulletstype    = PlayerBulletManager.bulletstype.EnemyFast;
                    for (int i = 0; i < bullets; i++)
                    {
                        //Debug.Log("EnemyFast");
                        NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBullet", tempbullets);
                    }
                }
            }
        }
    }
Exemple #8
0
    void BrainBeAttacked(Notification noti)
    {
        PlayerBulletManager.Bullets b = (PlayerBulletManager.Bullets)noti.data;
        float harmful = 0;

        if (b.Bulletstype == PlayerBulletManager.bulletstype.EnemyFast)
        {
            harmful = b.harmful;
        }
        else
        {
            harmful = (1 - Vector3.Distance(transform.position, b.EndPosition) / 5) * b.harmful;
            if (harmful <= 0)
            {
                harmful = 0f;
            }
        }
        HP -= harmful;
    }
Exemple #9
0
    void HitRobot(Notification noti)
    {
        PlayerBulletManager.Bullets b = (PlayerBulletManager.Bullets)noti.data;

        if (b.Target.transform.parent.name.Equals(gameObject.name))
        {
            HP = HP - b.harmful;
            NotificationCenter.DefaultCenter().PostNotification(this, "HitEnemyP", b.EndPosition);
            // Vector3 direction = transform.position - EnemyTarget.transform.position;
            // m_rigid.velocity = direction.normalized;
            if (HP <= 0 && !haddead)
            {
                NotificationCenter.DefaultCenter().PostNotification(this, "RobotDead");
                NotificationCenter.DefaultCenter().PostNotification(this, "DeadEnemyP", b.Target.transform.position);
                GetComponentInChildren <SphereCollider>().enabled = false;
                DestroyObject(gameObject, 2);
                haddead = true;
            }
        }
    }
 void PlayerBeAttacked(Notification noti)
 {
     PlayerBulletManager.Bullets b = (PlayerBulletManager.Bullets)noti.data;
     if (b.Bulletstype == PlayerBulletManager.bulletstype.EnemyFast)
     {
         NotificationCenter.DefaultCenter().PostNotification(this, "BrainBeAttacked", b);
         m_Animator.SetBool("BeAttacked", true);
         m_isAttackeding = true;
         isAttackedtime  = 0;
     }
     else
     {
         float distance = Vector3.Distance(b.EndPosition, transform.position);
         //Debug.Log("distance"+distance);
         if (distance < 3 && !m_rushing)
         {
             NotificationCenter.DefaultCenter().PostNotification(this, "BrainBeAttacked", b);
             m_Animator.SetBool("BeAttacked", true);
             m_isAttackeding = true;
             isAttackedtime  = 0;
         }
     }
 }
 // Update is called once per frame
 void Update()
 {
     St += Time.deltaTime;
     if (St >= 1 && !hasSpawnSphere)
     {
         hasSpawnSphere = true;
         gameObject.AddComponent <SphereCollider>();
         Ss = 0;
         GetComponent <SphereCollider>().radius = 3;
         PlayerBulletManager.Bullets tempb = new PlayerBulletManager.Bullets();
         tempb.EndPosition = transform.position;
         tempb.Bulletstype = PlayerBulletManager.bulletstype.EnemySlow;
         tempb.harmful     = 30;
         NotificationCenter.DefaultCenter().PostNotification(this, "PlayerBeAttacked", tempb);
     }
     if (hasSpawnSphere)
     {
         Ss += Time.deltaTime;
         if (Ss >= 0.1)
         {
             gameObject.GetComponent <SphereCollider>().enabled = false;
         }
     }
 }