コード例 #1
0
    public void AddPower(Power power)
    {
        //Deactivate any previous power

        Power old_power = null;

        if (powers.TryGetValue(power.Group, out old_power))
        {
            old_power.Deactivate();
            powers.Remove(old_power.Group);
        }

        //Activate and add the power to the bag

        power.Activate(gameObject);

        powers.Add(power.Group, power);

        power.EventDestroyed += RemovePower;

        //Relay the call to others

        if (Network.isServer)
        {
            networkView.RPC("RPCAddPower", RPCMode.Others, power.Name);
        }

        //Fires the attach event
        if (EventPowerAttached != null)
        {
            EventPowerAttached(this, gameObject, power);
        }
    }