Exemple #1
0
        public bool Recieve(Entity that)
        {
            Ore toSell = that as Ore;

            if (toSell == null)
            {
                return(false);
            }

            toSell.Die();
            _context.FactionContext().Credits += Constants.Global.ORE_SELL_VALUE;

            return(true);
        }
        public bool AddEntity(byte type, ByteVector2 position)
        {
            int freeIndex = GetFreeEntityIndex();

            if (freeIndex < 0)
            {
                Debug.Log("ERROR: No free index!");
                return(false);
            }

            Context context = new Context(freeIndex, FactionID, GameManager);

            Entity toAdd = null;

            switch (type)
            {
            // Hub
            case Constants.Entities.Hub.ID:
                toAdd = new Hub(position, context);
                break;

            // Dummy items
            case Constants.Entities.Ore.ID:
                toAdd = new Ore(position, context);
                break;

            // Units
            case Constants.Entities.Miner.ID:
                toAdd = new Miner(position, context);
                break;

            case Constants.Entities.Digger.ID:
                toAdd = new Digger(position, context);
                break;

            case Constants.Entities.Soldier.ID:
                toAdd = new Soldier(position, context);
                break;

            case Constants.Entities.Hauler.ID:
                toAdd = new Hauler(position, context);
                break;

            // Deployables
            case Constants.Entities.ProximityMine.ID:
                toAdd = new ProximityMine(position, context);
                break;

            case Constants.Entities.TimeBomb.ID:
                toAdd = new TimeBomb(position, context);
                break;

            case Constants.Entities.QuickSand.ID:
                toAdd = new QuickSand(position, context);
                break;

            case Constants.Entities.GasBomb.ID:
                toAdd = new GasBomb(position, context);
                break;

            case Constants.Entities.HealStation.ID:
                toAdd = new HealStation(position, context);
                break;

            case Constants.Entities.SonicBomb.ID:
                toAdd = new SonicBomb(position, context);
                break;

            case Constants.Entities.AntimatterBomb.ID:
                toAdd = new AntimatterBomb(position, context);
                break;

            case Constants.Entities.SandBags.ID:
                toAdd = new SandBags(position, context);
                break;
            }

            if (toAdd == null)
            {
                Debug.Log("ERROR: Failed to add entity!");
                return(false);
            }

            Entities[freeIndex] = toAdd;
            return(true);
        }