Exemple #1
0
    void SetAbility(GameObject toAbilitize, PlayerData pd)
    {
        Abilities myAbility = pd.PlayerAbility;

        shield leShield = toAbilitize.GetComponent <shield>();

        leShield.ChangeVisibilty(leShield.m_Gun);
        leShield.enabled = false;

        IDartGun leDart = toAbilitize.GetComponent <IDartGun>();

        leDart.enabled = false;

        MeleeAttack[] leMelees     = toAbilitize.GetComponents <MeleeAttack>();
        MeleeAttack   abilityMelee = null;
        MeleeAttack   normalMelee  = null;

        foreach (MeleeAttack ma in leMelees)
        {
            if (ma.isAbility)
            {
                abilityMelee = ma;
            }
            else
            {
                normalMelee = ma;
            }
        }
        if (abilityMelee != null)
        {
            abilityMelee.enabled = false;
        }

        switch (myAbility)
        {
        case Abilities.AbsorbShield:
            leShield.enabled = true;
            break;

        case Abilities.DoubleJump:
            break;

        case Abilities.Dart:
            leDart.enabled = true;
            break;

        case Abilities.Melee:
            normalMelee.enabled  = false;
            abilityMelee.enabled = true;
            break;

        case Abilities.None:
            break;
        }
    }
Exemple #2
0
    private void Awake()
    {
        Shield         = GameObject.Find("Shield");
        _shootingPoint = transform.Find("Shooting Point");

        _spawnManager = GameObject.Find("Spawner").GetComponent <SpawnManager>();

        _UiManager = GameObject.Find("Canvas").GetComponent <UiManager>();

        _audio = GetComponent <AudioSource>();

        _shieldscript = GameObject.Find("Shield").GetComponent <shield>();

        _shaking = GameObject.Find("Main Camera").GetComponent <CameraShaking>();
    }
Exemple #3
0
 //Create a main class needed to execute the program.
 static void Main(string[] args)
 {
     //Create a new instance of the sword class, give it a cost, equip, unequip it, then sell it.
     Sword sword = new Sword("Cutting Sword of cutting");
     sword.itemCost = 2;
     sword.equip();
     sword.unequip();
     sword.sell();
     //Create a shield instance with an override of the abstract block method.
     shield shield = new shield("Blocking Shield of blocking");
     //Block an attack.
     shield.block();
     //Keep the console open until the user clicks a key.
     Console.WriteLine("Press any key to exit.");
     Console.ReadKey();
 }