Exemplo n.º 1
0
    public override void SpecialEffect()
    {
        if (gameObject.tag == "PlayerSkill")
        {
            maxBounceCount += GameManager.Instance.aoeUpgrade;
        }

        if (!hit)
        {
            if (opponent != null)
            {
                lightningArea = Instantiate(lightningArea, opponent.transform.position, opponent.transform.rotation) as GameObject;
                LightningField lightningField = lightningArea.GetComponent <LightningField>();
                if (gameObject.tag == "PlayerSkill")
                {
                    lightningArea.tag = "PlayerSkill";
                }
                if (gameObject.tag == "EnemySkill")
                {
                    lightningArea.tag = "EnemySkill";
                }

                lightningField.damage          = damage;
                lightningField.maxBounceCount  = maxBounceCount;
                lightningField.bounceMaxLength = bounceMaxLength;
                lightningField.SetCurrentBounceToZero();

                hit = true;
            }
        }



        Destroy(gameObject);
    }
     public void Update()
     {
          isInvincible = false;
          if (player != null)
          {
               //find position after animation? will it use the position from before the animation starts? be ready to change
               findPos();

               if (!supercharged && currentHp() <= health.startingHealth / 2)
               {
                    supercharged = true;
                    cd_Reduction = 3;
                    overload_Range *= 1.5;
                    bolt_Stun += 0.5f;
                    hook_Speed *= 1.5f;
                    knockback += 1.5f;
                    speedBoost++;
                    storm_CD = 0.6f;

               }
               rnd = new System.Random();


               //if stunned = true, wait 0.5s, then gain a speedBoost for 3s
               //else

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

               if (isAgro)
               {
                    //targetPos *= 0.8f;
                    if (cooldown_CD > 1)
                    {
                         cooldown_CD = 0;
                         //faster the closer you are from him, probably better ways to do this but I don't want to look it up
                         float xSp = 2 * (AgroRange - (player.transform.position.x - transform.position.x));
                         float ySp = 2 * (AgroRange - (player.transform.position.y - transform.position.y));
                         //targetPos = new Vector2(0, 0);
                         moveController.Move(0, 0);
                         //basic aggression range formula
                         if (distance.magnitude < overload_Range && overload_CD > 12 - cd_Reduction)
                         {
                              overloadAttack();
                         }
                         else if (distance.magnitude < 0.3 && norm_CD > 1.5)
                         {
                              normAttack();
                         }
                         else if (lightning_CD > 10)
                         {
                              //animation
                              //lightning storm, player parameter or getObject(player)
                              //take in either bool supercharged or cooldown
                              //field = new LightningField();

                              field = Instantiate(fieldObj, player.transform.position, transform.rotation) as LightningField;
                              field.set(0.7f, storm_CD);
                              lightning_CD = 0;
                              //dark shadow below player?
                         }
                         else if (bolt_CD > 10 - cd_Reduction)
                         {
                              boltAttack();
                         }
                         //overload -> normal attack if in range -> lightning storm (effect) -> lightning bolt projectile(to set up other moves)
                         //-> thunder (put bolt here instead? depends on thunder activation speed)-> shot -> field -> speed -> charge
                         else if (supercharged && thunder_CD > 20)
                         {
                              //animation
                              //thunder, parameter player or getobject
                              //in thunder class, create black white black screen around player
                              //indic = new Indicator();

                              //indic.set or indicObj.set?
                              indic = Instantiate(indicObj, player.transform.position, transform.rotation) as Indicator;
                              indic.set(2);
                              thunder_CD = 0;
                         }
                         else if (shot_CD > 10 - cd_Reduction)
                         {
                              shotAttack();
                         }
                         else
                         {
                              //if wall within 0.2 units of one corner, move to another corner clockwise
                              //else
                              //if wall(not pole) to the left or right, disregard x velocity and increase y velocity
                              //if wall(not pole) above or below, disregard y velocity and increase x velocity
                              //else move away from player
                              cooldown_CD = 0.8f;
                         }
                         if (spark_CD > 2 + currentHp() / 5.0)
                         {
                              sparkAttack();
                         }
                    }
                    //moveController.Move(targetPos);
                    // float xSp = player.transform.position.x - transform.position.x;
                    // float ySp = player.transform.position.y - transform.position.y;




                    overload_CD += Time.deltaTime;
                    norm_CD += Time.deltaTime;
                    lightning_CD += Time.deltaTime;
                    bolt_CD += Time.deltaTime;
                    shot_CD += Time.deltaTime;
                    thunder_CD += Time.deltaTime;
                    cooldown_CD += Time.deltaTime;
                    spark_CD += Time.deltaTime;

               }
          }
          //Debug.Log("My pos is " + posArr[9 - currentHp()]);
          findPos();
          transform.position = posArr[9 - currentHp()];
          if (currentHp() > 5)
          {
               transform.rotation = Quaternion.Euler(0, 0, 90 * (9 - currentHp()));
          }
          else if (currentHp() > 1)
          {
               transform.rotation = Quaternion.Euler(0, 0, 45 + 90 * (5 - currentHp()));
          }
          else
          {
               transform.rotation = Quaternion.Euler(0, 0, 0);
          }

     }