예제 #1
0
        public Structure(StructureType type, Point tilePosition, Unit builder, short team)
            : this(type, tilePosition, team)
        {
            UnderConstruction = true;
            PercentDone       = 0f;
            Builder           = builder;
            //preciseHp = MaxHp * STARTING_HP_PERCENT;
            Hp = (int)(MaxHp * STARTING_HP_PERCENT);
            constructionHpPerTick = (MaxHp - (MaxHp * STARTING_HP_PERCENT)) / (BuildTime / 1000) / 8;

            //((Rts)Game1.Game.CurrentGameState).CogWheels.Add(new StructureCogWheel(this, (int)(Type.Size * Map.TileSize / 2.5f)));
            //if (team == Player.Me.Team)
            //{
            CogWheel = new StructureCogWheel(this, (int)(type.Size * Rts.map.TileSize / 2.5f));
            ((Rts)Game1.Game.CurrentGameState).CogWheels.Add(CogWheel);
            //}

            foreach (PathNode pathNode in OccupiedPathNodes)
            {
                foreach (Unit unit in pathNode.UnitsContained)
                {
                    if (unit != Builder)
                    {
                        unit.PushSimple((float)(rand.NextDouble() * MathHelper.TwoPi), Radius * .5f);
                        //unit.CheckForPush(true);
                        unit.CheckForWallHit();
                    }
                }
            }
        }
예제 #2
0
        void finishConstruction()
        {
            Player.Players[Team].MaxSupply += type.Supply;
            UnderConstruction = false;
            PercentDone       = 1f;

            if (!HasTakenDamageEver)
            {
                Hp = MaxHp;
            }

            releaseBuilder();
            ((Rts)Game1.Game.CurrentGameState).CheckForResetCommandCardWhenStructureCompletes(this);
            CogWheel = null;
        }
예제 #3
0
        public override void Die()
        {
            base.Die();

            if (!UnderConstruction)
            {
                Player.Players[Team].MaxSupply -= type.Supply;
            }

            foreach (Structure structure in Structures)
            {
                structure.HasMoved = true;
            }

            UnitAnimation a = new UnitAnimation(this, Width, .5f, true, Structure.Explosion1Textures);

            a.Start();

            foreach (PathNode node in OccupiedPathNodes)
            {
                node.Blocked = false;
                node.Blocker = null;
            }

            if (Builder != null)
            {
                releaseBuilder();
                ((Rts)Game1.Game.CurrentGameState).CheckForResetCommandCardWhenStructureCompletes(this);
                CogWheel = null;
            }

            Player.Players[Team].StructureIDsToSetNull.Add(new KeyValuePair <short, float>(ID, Rts.GameClock));

            NetOutgoingMessage msg = Rts.netPeer.CreateMessage();

            msg.Write(MessageID.STRUCTURE_DEATH);
            msg.Write(ID);
            msg.Write(Team);
            Rts.netPeer.SendMessage(msg, Rts.connection, NetDeliveryMethod.ReliableUnordered);
        }
예제 #4
0
파일: Structure.cs 프로젝트: nubington/rts
        public Structure(StructureType type, Point tilePosition, Unit builder, short team)
            : this(type, tilePosition, team)
        {
            UnderConstruction = true;
            PercentDone = 0f;
            Builder = builder;
            //preciseHp = MaxHp * STARTING_HP_PERCENT;
            Hp = (int)(MaxHp * STARTING_HP_PERCENT);
            constructionHpPerTick = (MaxHp - (MaxHp * STARTING_HP_PERCENT)) / (BuildTime / 1000) / 8;

            //((Rts)Game1.Game.CurrentGameState).CogWheels.Add(new StructureCogWheel(this, (int)(Type.Size * Map.TileSize / 2.5f)));
            //if (team == Player.Me.Team)
            //{
                CogWheel = new StructureCogWheel(this, (int)(type.Size * Rts.map.TileSize / 2.5f));
                ((Rts)Game1.Game.CurrentGameState).CogWheels.Add(CogWheel);
            //}

                foreach (PathNode pathNode in OccupiedPathNodes)
                {
                    foreach (Unit unit in pathNode.UnitsContained)
                    {
                        if (unit != Builder)
                        {
                            unit.PushSimple((float)(rand.NextDouble() * MathHelper.TwoPi), Radius * .5f);
                            //unit.CheckForPush(true);
                            unit.CheckForWallHit();
                        }
                    }
                }
        }