Esempio n. 1
0
    public override void Init(bool defaultStats = false)
    {
        base.Init(defaultStats);

        if (defaultStats)
        {
            maxHealth     = 10;
            health        = 10;
            defense       = 4;
            physAtk       = 5;
            energyAtk     = 10;
            speed         = 4;
            movementRange = 4;

            // WEAPON(S):
            weapons = new List <Weapon>();

            Weapon rifle = new Rifle(this);
            weapons.Add(rifle);
            Equip(rifle);
            Weapon beamsword = new BeamSword(this);
            weapons.Add(beamsword);
            Equip(beamsword);
            Weapon frag = new Frag(this);
            weapons.Add(frag);
            //weapons.Add(new LaserCannon(this));
            //weapons.Add(new PhotonEqualizer(this));
            //weapons.Add(new EnergyChain(this));
        }

        UpdateStats();
    }
    void initWeapon(string s, Unit script)
    {
        if (GameDirector.Instance.isMultiPlayer())
        {
            script.gameObject.GetPhotonView().RPC("AddWeapon", PhotonTargets.AllBuffered, s);
            return;
        }

        if (script.weapons == null)
        {
            script.weapons = new List <Weapon>();
        }
        switch (s)
        {
        case "Sword":
        {
            Weapon sword = new BeamSword(script);
            script.weapons.Add(sword);
            script.Equip(sword);
            break;
        }

        case "Rifle":
        {
            Weapon rifle = new Rifle(script);
            script.weapons.Add(rifle);
            script.Equip(rifle);
            break;
        }

        case "Frag":
        {
            Weapon frag = new Frag(script);
            script.weapons.Add(frag);
            script.Equip(frag);
            break;
        }

        case "Laser":
        {
            Weapon laser = new LaserCannon(script);
            script.weapons.Add(laser);
            script.Equip(laser);
            break;
        }

        case "Chain":
        {
            Weapon chain = new EnergyChain(script);
            script.weapons.Add(chain);
            script.Equip(chain);
            break;
        }

        case "Photon":
        {
            Weapon photon = new PhotonEqualizer(script);
            script.weapons.Add(photon);
            script.Equip(photon);
            break;
        }

        default:
        {
            Debug.Log("Unit not found");
            break;
        }
        }
    }
    public void AddWeapon(string s)
    {
        Unit script = gameObject.GetComponent <Unit>();

        if (script.weapons == null)
        {
            script.weapons = new List <Weapon>();
        }
        switch (s)
        {
        case "Sword":
        {
            Weapon sword = new BeamSword(script);
            script.weapons.Add(sword);
            script.Equip(sword);
            break;
        }

        case "Rifle":
        {
            Weapon rifle = new Rifle(script);
            script.weapons.Add(rifle);
            script.Equip(rifle);
            break;
        }

        case "Frag":
        {
            Weapon frag = new Frag(script);
            script.weapons.Add(frag);
            script.Equip(frag);
            break;
        }

        case "Laser":
        {
            Weapon laser = new LaserCannon(script);
            script.weapons.Add(laser);
            script.Equip(laser);
            break;
        }

        case "Chain":
        {
            Weapon chain = new EnergyChain(script);
            script.weapons.Add(chain);
            script.Equip(chain);
            break;
        }

        case "Photon":
        {
            Weapon photon = new PhotonEqualizer(script);
            script.weapons.Add(photon);
            script.Equip(photon);
            break;
        }

        default:
        {
            Debug.Log("Unit not found");
            break;
        }
        }
    }