public void Update()
          {
               if (player != null)
               {

                    distance = player.transform.position - transform.position;
                    if (distance.magnitude <= AgroRange)
                    {
                         isAgro = true;
                    }
                    if (distance.magnitude > AgroRange)
                    {
                         isAgro = false;
                         shot_CD = 0;
                    }

                    if (isAgro)
                    {
                         if (shot_CD < 0)
                         {
                              shot_CD = 1;
                              wind = Instantiate(windObject, transform.position, transform.rotation) as Projectile;
                         }
                         shot_CD -= Time.deltaTime;
                    }
               }

          }
Exemple #2
0
        private void HandleShooting(int _type, Projectile shot)
        {
            switch(_type)
            {
                case 0 :
                    shot.Initialize(1.1f, 10, "minigun");
                break;

                case 1 :
                    shot.Initialize(0.25f, 1, "plasma");
                break;
            }
        }
          public void Update()
          {
               checkInvincibility();
               if (checkStun())
               {
                    stunTimer -= Time.deltaTime;
                    moveController.Move(0, 0);
               }
               else
               {
                    vel = rigidbody.velocity.magnitude;
                    rnd = new System.Random();
                    currentX = transform.position.x;
                    currentY = transform.position.y;

                    //to offset fireblocks to be a bit behind the flamie, so arrows and sword swings hit the flamie instead of the blocks
                    //Vector3 fireVect = new Vector3(direction.normalized.x/(-8), direction.normalized.y/(-8), 0);

                    //place fire block that deals damage to enemy (projectile that stays in one spot?)
                    //time = distance/speed, create new block after passing the old one.
                    if (vel > 0.1 && fireBlock_CD > .28 / vel)
                    {
                         fireBlock = Instantiate(fireBlockObject, new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.1f), transform.rotation) as Projectile;
                         fireBlock_CD = 0;
                    }
                    else if (vel < 0.1 && fireBlock_CD > 1)
                    {
                         fireBlock = Instantiate(fireBlockObject, new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.1f), transform.rotation) as Projectile;
                         fireBlock_CD = 0;

                    }
                    if (player != null)
                    {
                         //basic aggression range formula
                         playerPos = player.transform;
                         float xSp = player.transform.position.x - transform.position.x;
                         float ySp = player.transform.position.y - transform.position.y;
                         direction = new Vector2(xSp, ySp);

                         distance = playerPos.position - transform.position;
                         if (distance.magnitude <= AgroRange)
                         {
                              isAgro = true;

                         }
                         if (distance.magnitude > AgroRange)
                         {
                              isAgro = false;
                         }

                         if (isAgro)
                         {

                              moveController.Move(direction.normalized, 8);

                         }
                         else
                         {
                              if (idleTime > 0.4)
                              {
                                   someVec = idle(t, rnd);
                                   t = someVec.z;
                                   idleTime = 0;
                              }
                              moveController.Move(someVec.x, someVec.y);
                         }

                         idleTime += Time.deltaTime;
                         t -= Time.deltaTime;
                         fireBlock_CD += Time.deltaTime;
                         //cd1 += Time.deltaTime;
                         //cd2 += Time.deltaTime;
                    }
               }
               if (health.currentHp() == 0)
               {
                    onDeath();
               }

          }