예제 #1
0
    public virtual float Injure(float amount, GameObject Attacker)
    {
        if (IsInvincible)
        {
            return(0);
        }

        float overkillDamage = 0;

        if (amount > Health)
        {
            overkillDamage = amount - Health;
        }

        //Health -= amount;
        Health = MathM.MinimumClamped(Health - amount, 0);

        LocalMessenger.Fire(MESSAGE_INJURED, new object[] { Attacker });

        if (!IsAlive())
        {
            OnDeath();
        }

        return(overkillDamage);
    }
예제 #2
0
    void CheckForGamepadJoin(int controllerNumber)
    {
        if (GamepadPlayers[controllerNumber] == null && Input.GetButtonDown("Fire1 Gamepad" + controllerNumber.ToString()))
        {
            var slotNumber = GetNextFreePlayerSlot();

            var inputData = new InputData {
                PlayerSlot          = slotNumber,
                InputControllerType = InputControllerType.Gamepad,
                GamepadNumber       = controllerNumber
            };

            GamepadPlayers[controllerNumber] = inputData;
            PlayerSlots[slotNumber]          = inputData;

            LocalMessenger.Fire(PLAYER_JOINED, new object[] { inputData });
        }
    }
 void Fire(string statKey, string functionName, object[] args)
 {
     if (LocalMessenger == null)
     {
         Messenger.Fire("{0}{1}{2}".FormatWith(Prefix, statKey, functionName), args);
     }
     else
     {
         LocalMessenger.Fire("{0}{1}".FormatWith(statKey, functionName), args);
     }
 }
예제 #4
0
    public void Pop()
    {
        if (IsPopping)
        {
            return;
        }
        IsPopping = true;

        var popPrefab = GameObject.Instantiate <GameObject>(PopPrefab);

        popPrefab.transform.position = transform.position;

        popPrefab.GetComponent <AudioSource>().pitch = Random.Range(0.6f, 1.0f);
        var particleSystemMain = popPrefab.GetComponent <ParticleSystem>().main;

        particleSystemMain.startColor = BalloonData.PopColor;

        Destroy(popPrefab, 1);
        Destroy(gameObject);

        Messenger.Fire(MESSAGE_BALLOON_POPPED);
        LocalMessenger.Fire(MESSAGE_POP);
    }
예제 #5
0
    public void Recalculate(object[] args = null)
    {
        Stats.Clear();

        // Preloading all of the PersistentStatBonuses into the stats
        foreach (var statBonusPair in PersistentStats)
        {
            var statBonus = statBonusPair.Value;
            Add(statBonus.Name, statBonus.Value);
        }

        foreach (var provider in TransientStatProviders)
        {
            var stats = provider.GetStats();
            foreach (var stat in stats)
            {
                Add(stat.Name, (int)stat.Value);
            }
        }

        SpecificRecalulate();

        LocalMessenger.Fire(AFTER_RECALCULATE);
    }