Exemplo n.º 1
0
    void Start()
    {
        _motor         = _bodyIdentity.gameObject.GetComponent <BaseMotor>();
        _abilities     = _bodyIdentity.gameObject.GetComponent <AbilityList>();
        _animationSync = _bodyIdentity.gameObject.GetComponent <AnimationSync>();


        if (isServer)
        {
            _abilities.GrantAbility(new AbilityJump(_motor, _animationSync), AbilitySlot.Jump);
            _abilities.GrantAbility(new AbilityBasicAttack(_motor, _animationSync), AbilitySlot.Attack1);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// The server should really be the one to grant abilities, but this makes it possible from the client.
    /// </summary>
    private void CmdGrantAbility(string abilityType, int slotInt)
    {
        Type type = Type.GetType(abilityType);

        System.Object instance = Activator.CreateInstance(type, new object[] { _motor });

        if (instance is BaseAbility)
        {
            AbilitySlot slot = (AbilitySlot)slotInt;
            _abilities.GrantAbility(instance as BaseAbility, slot);
        }
        else
        {
            Debug.LogError("Type \"" + abilityType + "\" can't be assigned as a BaseAbility object. Aborting CmdGrantAbility");
        }
    }