예제 #1
0
        public static void tryCaptureTower(Objects.playerObject player)
        {
            List <Grid.GridObjectInterface> list = GameController.Grid.checkNeighbouringBlocks(player);

            foreach (Grid.GridObjectInterface item in list)
            {
                if (item is Objects.Turret && (item.Position - player.Position).Length() <= MAX_CAPTURE_DISTANCE)
                {
                    Objects.Turret turret = ((Objects.Turret)item);
                    if (turret.Team.Equals(Objects.Team.neutral))
                    {
                        turret.changeTeam(player.Team);
                        GameController.AIController.registerTurretOnTeam(turret, player.Team);
                        if (player.Team == Objects.Team.Red)
                        {
                            Controller.GameController.Team1Gold.Add(TradingInformation.creditsForCapturingTower.ToString());
                            Controller.GameController.team1.teamCredits += TradingInformation.creditsForCapturingTower;
                        }
                        else
                        {
                            Controller.GameController.Team2Gold.Add(TradingInformation.creditsForCapturingTower.ToString());
                            Controller.GameController.team2.teamCredits += TradingInformation.creditsForCapturingTower;
                        }
                        break;
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Loads content item subtree from Map tree
 /// </summary>
 /// <param name="reader">XML Reader @ contentItem</param>
 private void readContentItemData(XmlReader reader)
 {
     String id = reader.GetAttribute("id");
     String className = reader.GetAttribute("className");
     String type = reader.GetAttribute("type");
     int owningTeam = 0;
     float x = 0, y = 0, z = 0, yaw = 0, pitch = 0, roll = 0, scaleX = 0, scaleY = 0, scaleZ = 0;
     String modelName = "";
     XmlReader subtree = reader.ReadSubtree();
     while (subtree.Read())
         if (subtree.NodeType == XmlNodeType.Element)
             switch (subtree.Name)
             {
                 case "x":
                     x = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "y":
                     y = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "z":
                     z = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "yaw":
                     yaw = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "pitch":
                     pitch = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "roll":
                     roll = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "scaleX":
                     scaleX = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "scaleY":
                     scaleY = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "scaleZ":
                     scaleZ = Convert.ToSingle(subtree.ReadString());
                     break;
                 case "modelName":
                     modelName = subtree.ReadString();
                     break;
                 case "owningTeam":
                     owningTeam = Convert.ToInt32(subtree.ReadString());
                     break;
             }
     //now just make them into objects:
     switch (className)
     {
         case "Base":
             Objects.Base b = new Objects.Base(game, getTeamFromMapTeamId(owningTeam), new Vector3(x, y, z));
             b.rotation = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll);
             addObject(b);
             if (b.Team == BBN_Game.Objects.Team.Red)
                 Team1Base = b;
             else if (b.Team == BBN_Game.Objects.Team.Blue)
                 Team2Base = b;
             break;
         case "Tower":
             Objects.Turret t = new Objects.Turret(game, getTeamFromMapTeamId(owningTeam), new Vector3(x, y, z));
             t.rotation = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll);
             addObject(t);
             break;
         case "Astroid":
             Asteroid a = new Asteroid(game,Team.neutral,new Vector3(x,y,z));
             a.rotation = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll);
             addObject(a);
             break;
     }
 }