示例#1
0
 void Update()
 {
     if (image)
     {
         Power p = action as Power;
         if (p && p.coolDown > 0)
         {
             image.fillAmount = caster.GetCoolDownFactor(p);
         }
         else
         {
             image.fillAmount = 1.0f;
         }
         if (p && button.image)
         {
             Color color = p.CanUse(caster) ? p.tint.GetColor() : p.tint.GetColor() * 0.5f;
             color.a            = 1;
             button.image.color = color;
             PowerToggle pt = action as PowerToggle;
             if (pt)
             {
                 button.image.transform.localScale = Vector3.one * (pt.IsOn(caster) ? 0.9f : 1.0f);
             }
         }
     }
 }
示例#2
0
 static void MakeTogglePower()
 {
     RPG.Status      s     = Selection.activeObject as RPG.Status;
     RPG.PowerToggle power = CreateAsset <RPG.PowerToggle>(s.name + "Toggle");
     power.type       = GetDamageType(s, RPG.RPGSettings.DamageType.Magic);
     power.effects    = new RPG.Status[1];
     power.effects[0] = s;
 }
示例#3
0
        // Update is called once per frame
        void Update()
        {
            // count down animation lock
            if (animCountDown > 0)
            {
                animCountDown -= Time.deltaTime;
            }

            // count down combo windows
            if (currentComboTimer > 0)
            {
                currentComboTimer -= Time.deltaTime;
                if (currentComboTimer <= 0)
                {
                    ResetCombos();
                }
            }

            foreach (KeyValuePair <PowerToggle, PowerToggle.ToggleData> pair in toggles)
            {
                PowerToggle            power = pair.Key;
                PowerToggle.ToggleData data  = pair.Value;
                if (data.on)
                {
                    energy -= power.extraEnergyCost * Time.deltaTime;
                    if (energy == 0)
                    {
                        data.on = false;
                        power.EndToggle(this);
                    }
                }
            }

            UpdateStatus();

            // update health and energy over time
            energy += baseEnergyRegen * GetFactor(RPGSettings.StatName.EnergyRegen) * Time.deltaTime;
            if (energy > maxEnergy)
            {
                energy = maxEnergy;
            }
            health += baseHealthRegen * GetFactor(RPGSettings.StatName.HealthRegen) * Time.deltaTime;
            if (health > maxHealth)
            {
                health = maxHealth;
            }

            // update cooldowns
            float dt = Time.deltaTime * GetFactor(RPGSettings.StatName.Recharge);

            foreach (string p in coolDownPowers)
            {
                if (coolDowns[p] > 0)
                {
                    coolDowns[p] -= dt;
                    if (coolDowns[p] < 0)
                    {
                        coolDowns[p] = 0;
                    }
                }
            }
        }