Пример #1
0
 private void Update()
 {
     if (player)
     {
         if (player.ShotCount < GetMaxShot() && lastPlasmaCharge + GetPlasmaChargeRate() < Time.fixedTime)
         {
             lastPlasmaCharge  = Time.fixedTime;
             player.ShotCount += 1;
             //FindObjectOfType<LevelHandler>().UpdatePlayerStats();
         }
         else if (player.ShotCount > GetMaxShot())
         {
             player.ShotCount = GetMaxShot();
             lastPlasmaCharge = Time.fixedTime;
         }
         else if (player.ShotCount == GetMaxShot())
         {
             lastPlasmaCharge = Time.fixedTime;
         }
     }
     else
     {
         //if (FindObjectOfType<HornetController>())
         //Debug.Log("Looking for Player");
         player = FindObjectOfType <HornetController>();
     }
 }
Пример #2
0
    public void BeginBuff()
    {
        if (Unique)
        {
            print("Unique");
            SpeedBuff[] buffs = GetComponents <SpeedBuff>();
            for (int i = 0; i < buffs.Length; i++)
            {
                if (buffs[i].BuffName == BuffName && buffs[i] != this)
                {
                    print("Not Unique");
                    Destroy(this);
                    return;
                }
            }
        }

        entity = GetComponent <HornetController>();
        if (entity != null)
        {
            StartCoroutine(Buff());
        }
        else
        {
            Destroy(this);
        }
    }
    public void UpdatePlayerStats()
    {
        BeesMurderedText.text   = PlayerHandler.BeesMurderedCount.ToString();
        HornetMurderedText.text = PlayerHandler.HornetMurderedCount.ToString();

        PlayerHandler    ph = FindObjectOfType <PlayerHandler>();
        HornetController hc = FindObjectOfType <HornetController>();

        if (ph && hc)
        {
            float barPercent = hc.Health / ph.GetMaxHealth();
            HealthMeterBar.rectTransform.localScale = new Vector3(barPercent, 1, 1);
            HealthMeterText.text = hc.Health.ToString();

            float plasmaPercent = (float)hc.ShotCount / ph.GetMaxShot();
            PlasmaMeterBar.rectTransform.localScale = new Vector3(plasmaPercent, plasmaPercent, 1);
            PlasmaMeterText.text = hc.ShotCount.ToString();

            PlasmaPowerText.text          = (int)ph.GetPlasmaPower() + " " + (int)ph.GetPlasmaPowerBuffTime();
            PlasmaChargeRateText.text     = Utility.FormatFloat(ph.GetPlasmaChargeRate(), 2) + " " + (int)ph.GetPlasmaChargeRateBuffTime();
            PlasmaChargeCapacityText.text = ph.GetMaxShot() + " " + (int)ph.GetMaxShotBuffTime();
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            HornetController player = collision.GetComponent <HornetController>();
            if (rb.velocity.magnitude > 0.1)
            {
                // Direct hit
                print("Direct hit");
                player.TakeDamage(DamageDirect);
            }
            else
            {
                print("Indirect hit");
            }

            // Slow debuff
            SpeedBuff speedBuff = collision.gameObject.AddComponent <SpeedBuff>();
            speedBuff.BuffName       = "Spider Web";
            speedBuff.Duration       = 30f;
            speedBuff.Unique         = true;
            speedBuff.SpeedMuliplier = 0.5f;
            speedBuff.BeginBuff();

            // Damage over time
            if (dps == null)
            {
                dps                    = collision.gameObject.AddComponent <DamageDPS>();
                dps.BuffName           = "Spider Web";
                dps.Damage             = 1f;
                dps.Delay              = 0f;
                dps.ApplyDamageNTimes  = 30f;
                dps.ApplyEveryNSeconds = .1f;
                //dps.BeginDPS();
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     hornetController = GetComponent <HornetController>();
     cp = FindObjectOfType <ControlParameters>();
 }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (Player)
        {
            //Debug.Log(Player.velocity.magnitude);
            float pitch = AS.pitch;

            if (MyType == TestingType.continuous)
            {
                float percent = getSpeedPercent();
                pitch = percent * (MaxPitch - MinPitch) + MinPitch;
            }
            else if (MyType == TestingType.dualstep)
            {
                pitch = Player.velocity.magnitude < ((MaxSpeed - MinSpeed) / 2 + MinSpeed) ? MinPitch : MaxPitch;
            }
            else if (MyType == TestingType.slowcontinuous)
            {
                float pitchStep = (Player.velocity.magnitude < ((MaxSpeed - MinSpeed) / 2 + MinSpeed) ? -smoothing : smoothing) * Time.deltaTime;
                pitch += pitchStep;
            }
            else if (MyType == TestingType.slowdualstep)
            {
                float pitchStep = (Player.velocity.magnitude < ((MaxSpeed - MinSpeed) / 2 + MinSpeed) ? -smoothing : smoothing);//* Time.deltaTime;
                //Debug.Log("pitchStep: " + pitchStep );
                currentPitch += pitchStep * Time.deltaTime;
                currentPitch  = Mathf.Clamp(currentPitch, MinPitch, MaxPitch);
                if (currentPitch >= MaxPitch)
                {
                    pitch = MaxPitch;
                }
                else if (currentPitch <= MinPitch)
                {
                    pitch = MinPitch;
                }
            }
            else if (MyType == TestingType.averagecontinuous)
            {
                float speed = Mathf.Clamp(Player.velocity.magnitude, MinSpeed, MaxSpeed);
                averageVelocity = (speed * smoothing + (1 - smoothing) * averageVelocity);
                float percent = getSpeedPercent(averageVelocity);
                pitch = percent * (MaxPitch - MinPitch) + MinPitch;
            }
            else
            {
                if (MaxPitch < Pitch)
                {
                    MaxPitch = Pitch;
                }
                pitch = Pitch;
            }


            pitch          = Mathf.Clamp(pitch, MinPitch, MaxPitch);
            AS.pitch       = pitch;
            textPitch.text = pitch.ToString();
        }
        else
        {
            HornetController playerObj = FindObjectOfType <HornetController>();
            if (playerObj)
            {
                Player = playerObj.GetComponent <Rigidbody2D>();
            }
        }
    }