コード例 #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();
                        }
                    }
                }
        }