Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        this.animator = GetComponent <Animator>();

        AudioSource aud       = GetComponent <AudioSource>();
        int         randSound = Random.Range(0, shotSounds.Count());

        aud.clip = shotSounds[randSound];

        // determine turret type from projectile
        switch (bulletPrefab.name)
        {
        case "ProjectileRocket":
            this.type = TurretTypes.RocketLauncher;
            break;

        case "ProjectileFireball":
            this.type = TurretTypes.FlameThrower;
            break;

        case "ProjectileTar":
            this.type = TurretTypes.TarSlinger;
            break;

        default:
            this.type = TurretTypes.MachineGun;
            break;
        }
    }
Beispiel #2
0
    private void InstantiateCorrectTurret(GameObject GO)
    {
        switch (GO.tag)
        {
        case "StandardTurret":
            thisTurretType = TurretTypes.STANDARDTURRET;
            break;

        case "LaserTurret":
            thisTurretType = TurretTypes.LASERTURRET;
            break;

        case "ElectricityTurret":
            thisTurretType = TurretTypes.ELECTRICITYTURRET;
            break;

        case "SniperTurret":
            thisTurretType = TurretTypes.SNIPERTURRET;
            break;

        case "RocketTurret":
            thisTurretType = TurretTypes.ROCKETTURRET;
            break;
        }
    }
        /// <summary>
        /// For structures which originate as StatefulCargo, as they already have a GalaxyID
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static IStructure CreateStructure(StatefulCargo c, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl)
        {
            IStructure s;

            switch (c.CargoType)
            {
            case (StatefulCargoTypes.LaserTurret):
            {
                TurretTypes t = owner.GetArea().AreaType == AreaTypes.Planet ? TurretTypes.Planet : TurretTypes.Space;
                s = new Turret(c.Id, xPos, yPos, owner.Id, currentAreaID, t, pl);
                break;
            }

            case (StatefulCargoTypes.DefensiveMine):
            {
                s = new DefensiveMine(xPos, yPos, c.Id, owner.Id, currentAreaID, pl);
                break;
            }

            default:
                throw new Exception("CreateStructure not implemented for structure type " + c.CargoType.ToString());
            }
            _galaxyRegistrationManager.RegisterObject(s);

            return(s);
        }
Beispiel #4
0
 public TurretLevelInfo(TurretTypes type, TurretField field, int level, float value)
 {
     this.type  = type;
     this.field = field;
     this.level = level;
     this.value = value;
 }
Beispiel #5
0
    /// <summary>
    /// Fetches the value a turret type will have at a given level.  Used for help screens.
    /// </summary>
    /// <param name="turretType">Turret type to fetch.</param>
    /// <param name="turretField">Turret field type to fetch.</param>
    /// <param name="turretLevel">Turret level.</param>
    /// <returns>Returns value of TurretField for a givent TurretType at a particular level.</returns>
    public static float GetData(TurretTypes turretType, TurretField turretField, int turretLevel)
    {
        var collection = from tli in TurretLevelData
                         where tli.type == turretType
                         where tli.level == turretLevel
                         where tli.field == turretField
                         select tli;
        TurretLevelInfo found = collection.First();

        return(found.value);
    }
 public TurretLaser(CollisionManager collisionManager,
                    SpriteBatch spriteBatch,
                    int ID,
                    byte firingWeaponSlot,
                    TurretTypes turretType,
                    World world)
     : base(collisionManager, spriteBatch, ID, firingWeaponSlot, world)
 {
     DrawColor   = Color.Red;
     _turretType = turretType;
 }
        /// <summary>
        /// Creates a structure
        /// </summary>
        /// <param name="type"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="owner"></param>
        /// <param name="commandCenter"></param>
        /// <param name="currentAreaID"></param>
        /// <param name="pl"></param>
        /// <param name="writeToDB">If true, must specify dbm</param>
        /// <param name="dbm">must be specified if writeToDB is true</param>
        /// <returns></returns>
        public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl, bool writeToDB = false, IDatabaseManager dbm = null)
        {
            IStructure s;

            switch (type)
            {
            case (StructureTypes.LaserTurret):
                TurretTypes t = owner.GetArea().AreaType == AreaTypes.Planet ? TurretTypes.Planet : TurretTypes.Space;
                s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner.Id, currentAreaID, t, pl);

                break;

            case (StructureTypes.Biodome):
                return(CreateBiodome(xPos, yPos, owner, currentAreaID));

            case (StructureTypes.PowerPlant):
                s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            case (StructureTypes.Silo):
                s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            case (StructureTypes.CommandCenter):
                return(CreateCommandCenter(xPos, yPos, owner, currentAreaID));

            case (StructureTypes.Factory):
                s = new Factory(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);
                break;

            default:
                throw new Exception("CreateStructure not implemented for structure type " + type.ToString());
            }
            _galaxyRegistrationManager.RegisterObject(s);

            if (writeToDB)
            {
                if (dbm == null)
                {
                    throw new Exception("Error: must specify IDatabaseManager dbm if writeToDB is true.");
                }
                else
                {
                    dbm.SaveAsync(s);
                }
            }

            return(s);
        }
Beispiel #8
0
    /*
     * public void BuyTurret()
     * {
     *     if(enoughlogs == true)
     *      {
     *          m_iLogs -= BeaverLauncherCost;
     *      }
     *  if (LogDisplay) LogDisplay.text = m_iLogs.ToString();
     * }
     */

    public void BuyTurret(TurretTypes _eType)
    {
        if (_eType == TurretTypes.BEAVERLAUNCHER)
        {
            if (CanBuyTurret(_eType))
            {
                m_iLogs -= BeaverLauncherCost;
                Mathf.Floor(BeaverLauncherCost *= 2.0f);
            }
        }
        if (LogDisplay)
        {
            LogDisplay.text = m_iLogs.ToString();
        }
    }
Beispiel #9
0
 public bool CanBuyTurret(TurretTypes _eType)
 {
     if (_eType == TurretTypes.BEAVERLAUNCHER)
     {
         if (m_iLogs >= BeaverLauncherCost)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Beispiel #10
0
 public void Action(GameObject obj)
 {
     updateGold();
     if ((obj.tag != "Upgrade" || obj.tag != "Delete") && Current_Gold >= Prices[Upgrade_Level])
     {
         InstantiateCorrectTurret(obj);
         Spawned_Tower = Instantiate(obj, Vector3.zero, Quaternion.identity, TowerParent.transform).transform;
         Spawned_Tower.localPosition = Vector3.zero;
         //Debug.Log("Purchased: " + obj.name + " for " + Prices[Upgrade_Level] + " gold");
         Current_Gold -= Prices[Upgrade_Level];
         goldController.GetComponent <GoldController>().ChangeGoldAmount(-Prices[Upgrade_Level]);
         ++Upgrade_Level;
         this.transform.parent.GetChild(6).GetChild(0).GetComponent <Text>().text = "UPGRADE: " + Prices[Upgrade_Level];
         //Debug.Log("New Gold amount: " + Current_Gold);
         HideButtons();
         // Perform graphical updates on tower to show creation via Spawned_Tower.transform..etc and take off gold
     }
     else if (obj.tag == "Upgrade" && Current_Gold >= Prices[Upgrade_Level])
     {
         if (Upgrade_Level < Max_Upgrade_Level)
         {
             Destroy(Spawned_Tower.gameObject);
             UpgradeToCorrectTurret();
             Spawned_Tower.localPosition = Vector3.zero;
             // Debug.Log("Upgraded: " + obj.name + " for " + Prices[Upgrade_Level] + " gold");
             Current_Gold -= Prices[Upgrade_Level];
             goldController.GetComponent <GoldController>().ChangeGoldAmount(-Prices[Upgrade_Level]);
             //Debug.Log("New Gold amount: " + Current_Gold);
             ++Upgrade_Level;
             this.transform.parent.GetChild(6).GetChild(0).GetComponent <Text>().text = "UPGRADE: " + Prices[Upgrade_Level];
             HideButtons();
             gameObject.GetComponent <TowerController>().TowerParent.transform.GetChild(1).GetComponent <RangeIndicatorController>().switchRangeIndicatorOff();
             // Perform graphical updates on tower to show upgrade via Spawned_Tower.transform..etc and take off gold
         }
     }
     else if (obj.tag == "Delete")
     {
         Destroy(Spawned_Tower.gameObject);
         thisTurretType = TurretTypes.NOTHING;
         obj.SetActive(true);
         //When Deleteing add half the amount of its current upgrade price back to players current gold
         Current_Gold += (Prices[Upgrade_Level - 1] / 2);
         goldController.GetComponent <GoldController>().ChangeGoldAmount((Prices[Upgrade_Level - 1] / 2));
         Upgrade_Level = 0;
         this.transform.parent.GetChild(6).GetChild(0).GetComponent <Text>().text = "UPGRADE: " + Prices[Upgrade_Level];
         HideButtons();
     }
 }
Beispiel #11
0
        }                                                 //Need to set this properly

        public Turret(
            MessageService_ToServer messageService,
            ProjectileManager projectileManager,
            Texture2D baseTexture,
            Texture2D headTexture,
            ClientShipManager clientShipManager,
            SpriteBatch spriteBatch,
            World w,
            Vector2 position,
            StructureTypes type,
            float health,
            int ID,
            int seed,
            TurretTypes turretType,
            HashSet <int> teams)
            : base(spriteBatch, headTexture, position.X, position.Y, StructureTypes.LaserTurret, health, ID, teams)
        {
            _messageService = messageService;
            Debugging.AddStack.Push(this.ToString());
            _body              = BodyFactory.CreateRectangle(w, .5f, .5f, 1, position);
            _body.IsStatic     = true;
            _body.UserData     = new StructureBodyDataObject(BodyTypes.Turret, this);
            _body.OnCollision += OnCollision;


            r = new Random(seed); // Sets a seed so that turrets fire at different times.

            _projectileManager = projectileManager;
            _clientShipManager = clientShipManager;

            Weapon = new TurretAltLaser(projectileManager, this, 1);
            Console.WriteLine(ID);

            Texture     = headTexture;
            BaseTexture = baseTexture;

            PotentialTargets = new Dictionary <int, ITargetable>();

            Teams = teams;

            IsBodyValid = true;

            TurretType = turretType;
        }
        public Turret CreateTurret(
            Vector2 position,
            float health,
            int ID,
            TurretTypes turretType,
            HashSet <int> teams
            )
        {
            var turret = new Turret(_messageManager,
                                    _projectileManager, GetTexture(StructureTypes.LaserTurret, false), GetTexture(StructureTypes.LaserTurret, true), _clientShipManager, _spriteBatch,
                                    _world, position, StructureTypes.LaserTurret,
                                    health, ID, _random.Next(int.MaxValue), turretType, teams
                                    );

            turret.IsAlliedWithPlanetOwner = true;//True by default, may change later
            RegisterStructure(turret);
            turret.IsLocalSim = _simulateStructures;

            return(turret);
        }
Beispiel #13
0
    public static GameObject GetTurret(TurretTypes name)
    {
        GameObject temp = null;

        switch (name)
        {
        case TurretTypes.MG:
            for (int i = 0; i < TurretPrefabs.Length; i++)
            {
                Debug.Log("Seaching...");
                if (TurretPrefabs[i].name == "MachineGunTurret")
                {
                    Debug.Log("Found");
                    temp = GameObject.Instantiate(TurretPrefabs[i], Vector3.zero, Quaternion.identity) as GameObject;
                }
            }
            return(temp);

        default:
            Debug.Log("Error No Projectile Prefab " + name);
            Debug.Break();
            return(null);
        }
    }
Beispiel #14
0
 public TurretModel(StructureModel <TurretStats> s, TurretTypes turretType) : base(s)
 {
     TurretType = turretType;
 }
 public override void setTurret(TurretTypes type)
 {
     Ttype = type;
 }
Beispiel #16
0
 public virtual void setTurret(TurretTypes type)
 {
 }
Beispiel #17
0
        public Turret(int galaxyID, float xPos, float yPos, int ownerID, int currentAreaID, TurretTypes turretType, IPlayerLocator pl)
            : base(xPos, yPos, galaxyID, ownerID, currentAreaID)
        {
            _model = new TurretModel(base._model, turretType);
            _model.StructureType = StructureTypes.LaserTurret;
            Debuffs = new DebuffHandler();

            Id = galaxyID;

            _playerLocator = pl;
            _model.Weapon  = new AltLaser();
        }