Example #1
0
		// Note: It is VERY important that the spell # here is the same as the one in the SpellTypes enum (see SpellTypesHelper).
		// PLEASE MAKE SURE TO MODIFY THEM AT BOTH PLACES.
		public static SpellTypes GetSpellFromAction(ChampionTypes type, PlayerActionType action)
		{
			switch (type) {
				case ChampionTypes.ManMega:
					switch (action) {
						case PlayerActionType.Spell1: return SpellTypes.ManMega_RocketRampage;
						case PlayerActionType.Spell2: return SpellTypes.ManMega_Slash;
						case PlayerActionType.Spell3: return SpellTypes.ManMega_HintOfASpark;
						case PlayerActionType.Spell4: return SpellTypes.ManMega_Shotgun;
					}
					break;

				case ChampionTypes.Zoro:
					switch (action) {
						case PlayerActionType.Spell1: return SpellTypes.Zoro_Tooth;
						case PlayerActionType.Spell2: return SpellTypes.Zoro_Slash;
						case PlayerActionType.Spell3: return SpellTypes.Zoro_Double;
						case PlayerActionType.Spell4: return SpellTypes.Zoro_Wall;
					}
					break;

					default:
					ILogger.Log("Champion type not implemented " + type + ".");
					break;
			}

			return SpellTypes.ManMega_RocketRampage; // Unknown spell: use one by default
		}
Example #2
0
        /// <summary>
        /// Adds the client to the current game.
        /// </summary>
        public void AddClient(NetConnection connection, ChampionTypes champ)
        {
            ILogger.Log("New player added to the game.", LogPriority.High);

            ServerChampion champion = CreateChampion(champ);
            ServerClient   client   = new ServerClient(connection, champion);

            // Send to the client that asked to join, along with the info of the current players
            List <ServerClient> remoteClients = new List <ServerClient>();

            foreach (ServerClient remote in Clients.Values)
            {
                remoteClients.Add(remote);
            }
            SendCommand(connection,
                        ServerCommand.JoinedGame,
                        NetDeliveryMethod.ReliableUnordered,
                        (msg) => FillJoinedGameMessage(msg, client, remoteClients));

            // Send the new player event to other players
            foreach (NetConnection clientConn in Clients.Keys)
            {
                if (clientConn != connection)
                {
                    SendCommand(clientConn,
                                ServerCommand.NewRemotePlayer,
                                NetDeliveryMethod.ReliableUnordered,
                                (msg) => FillNewRemotePlayerMessage(msg, client));
                }
            }

            // Apply the changes to our game state
            Clients.Add(connection, client);
            Match.CurrentState.AddEntity(champion);
        }
Example #3
0
        /// <summary>
        /// When we received data from one of our players.
        /// </summary>
        public void OnDataReceived(NetIncomingMessage message)
        {
            ClientCommand command = (ClientCommand)message.ReadByte();

            switch (command)
            {
            case ClientCommand.ActionPackage:
                OnActionPackage(message);
                break;

            case ClientCommand.StartGame:
                try {
                    ChampionTypes champ = (ChampionTypes)message.ReadUInt32();
                    AddClient(message.SenderConnection, champ);
                } catch (Exception e) {
                    ILogger.Log("Start game packet badly formatted: " + e.ToString(), LogPriority.Error);
                }
                break;

            default:
                Debug.Fail("Invalid client command.");
                ILogger.Log("Invalid client command received: " + command, LogPriority.Warning);
                break;
            }
        }
Example #4
0
			public Kill(ChampionTypes? killer, ChampionTypes? killed, bool FirstIsAlly, ChampionsInfo championsInfo) {
				AddChild(new DrawableImage("UIObjects/killed") {Position = new Vector2(60,0)});

				AddChild(new DrawableImage("UIObjects/deathCircle") {Tint = FirstIsAlly ? Color.Green : Color.Red});
				AddChild(new DrawableImage("UIObjects/innerDeathCircle") {Position = new Vector2(5)});
				AddChild(new DrawableImage("UIObjects/deathCircle") {Position = new Vector2(Width - 80,0),
					Tint = FirstIsAlly ? Color.Red : Color.Green});
				AddChild(new DrawableImage("UIObjects/innerDeathCircle") {Position = new Vector2(Width - 75,5)});

				if(killed == null ) {
					AddChild(new DrawableImage("UIObjects/towerDeath") {Position = new Vector2(Width - 60,12)});
				} else {
					AddChild(new DrawableImage(championsInfo.GetInfo(killed.Value).Portait) {Position = new Vector2(Width-75, 5)});
				}

				if(killer == null ) {
					AddChild(new DrawableImage("UIObjects/towerDeath") {Position = new Vector2(15,12)});
				} else {
					AddChild(new DrawableImage(championsInfo.GetInfo(killer.Value).Portait) {Position = new Vector2(5)});
				}


				MoveFinished = true;
				MoveCounter = 0;
				Timer = new TimeSpan(0,0,DurationShown);
				Remove = RemovingState.Alive;
			}
Example #5
0
        public bool IsCastingSpell(ChampionTypes champ, PlayerActionType action)
        {
            SpellTypes spell = ChampionTypesHelper.GetSpellFromAction(champ, action);

            return(TimeOfLastSpellUse(spell).TotalSeconds +
                   SpellsHelper.Info(spell).CastingTime.TotalSeconds >= Server.Instance.GetTime().TotalSeconds);
        }
Example #6
0
        /// <summary>
        /// Creates a champion.
        /// </summary>
        ServerChampion CreateChampion(ChampionTypes champ)
        {
            var team = GetSmallestTeam();

            return(new ServerChampion(IDGenerator.GenerateID(),
                                      GetSpawnPosition(team),
                                      champ,
                                      team));
        }
Example #7
0
 public ChampionSpawnInfo(ulong id, Vec2 spawn, ChampionTypes type, Teams team, float maxhp, float hp)
     : this()             // to be able to have automatic properties (http://stackoverflow.com/a/420441/395386)
 {
     ID = id;
     SpawningPosition = spawn;
     Type             = type;
     Team             = team;
     MaxHealth        = maxhp;
     Health           = hp;
 }
		public ChampionSpawnInfo(ulong id, Vec2 spawn, ChampionTypes type, Teams team, float maxhp, float hp) 
			: this() // to be able to have automatic properties (http://stackoverflow.com/a/420441/395386)
		{
			ID = id;
			SpawningPosition = spawn;
			Type = type;
			Team = team;
			MaxHealth = maxhp;
			Health = hp;
		}
 public DrawableChampionSprite(ChampionAnimation startAnim, ChampionTypes type, ChampionsInfo championsInfo)
     : base(championsInfo.GetInfo(type).AssetName,
            championsInfo.GetInfo(type).FrameWidth,
            championsInfo.GetInfo(type).FrameHeight,
            championsInfo.GetInfo(type).GetAnimation(startAnim).Line,
            championsInfo.GetInfo(type).GetAnimation(startAnim).FrameRate,
            championsInfo.GetInfo(type).GetAnimation(startAnim).FrameCount)
 {
     Information      = championsInfo.GetInfo(type);
     CurrentAnimation = startAnim;
 }
		public DrawableChampionSprite(ChampionAnimation startAnim, ChampionTypes type, ChampionsInfo championsInfo)
			: base (championsInfo.GetInfo(type).AssetName,
			        championsInfo.GetInfo(type).FrameWidth,
			        championsInfo.GetInfo(type).FrameHeight,
			        championsInfo.GetInfo(type).GetAnimation(startAnim).Line,
			        championsInfo.GetInfo(type).GetAnimation(startAnim).FrameRate,
			        championsInfo.GetInfo(type).GetAnimation(startAnim).FrameCount)
        {
			Information = championsInfo.GetInfo(type);
			CurrentAnimation = startAnim;
        }
Example #11
0
        public ICharacter(ulong id, Vec2 position, ChampionTypes type, Teams team)
			: base(id, position,
			       100f, 26f, 40f)//TODO: stats by champion
        {
			JumpForce = 800;
			HorizontalAcceleration = 9e-9f;

			Animation = ChampionAnimation.idle;
			FacingLeft = team == Teams.Right; // face the opposite team
			Team = team;
			Type = type;
        }
Example #12
0
        public ICharacter(ulong id, Vec2 position, ChampionTypes type, Teams team)
            : base(id, position,
                   100f, 26f, 40f)            //TODO: stats by champion
        {
            JumpForce = 800;
            HorizontalAcceleration = 9e-9f;

            Animation  = ChampionAnimation.idle;
            FacingLeft = team == Teams.Right;             // face the opposite team
            Team       = team;
            Type       = type;
        }
Example #13
0
        // Note: It is VERY important that the spell # here is the same as the one in the SpellTypes enum (see SpellTypesHelper).
        // PLEASE MAKE SURE TO MODIFY THEM AT BOTH PLACES.
        public static SpellTypes GetSpellFromAction(ChampionTypes type, PlayerActionType action)
        {
            switch (type)
            {
            case ChampionTypes.ManMega:
                switch (action)
                {
                case PlayerActionType.Spell1: return(SpellTypes.ManMega_RocketRampage);

                case PlayerActionType.Spell2: return(SpellTypes.ManMega_Slash);

                case PlayerActionType.Spell3: return(SpellTypes.ManMega_HintOfASpark);

                case PlayerActionType.Spell4: return(SpellTypes.ManMega_Shotgun);
                }
                break;

            case ChampionTypes.Zoro:
                switch (action)
                {
                case PlayerActionType.Spell1: return(SpellTypes.Zoro_Tooth);

                case PlayerActionType.Spell2: return(SpellTypes.Zoro_Slash);

                case PlayerActionType.Spell3: return(SpellTypes.Zoro_Double);

                case PlayerActionType.Spell4: return(SpellTypes.Zoro_Wall);
                }
                break;

            default:
                ILogger.Log("Champion type not implemented " + type + ".");
                break;
            }

            return(SpellTypes.ManMega_RocketRampage);            // Unknown spell: use one by default
        }
Example #14
0
		public ChampionInfo GetInfo(ChampionTypes champion)
		{
			Debug.Assert(Info.ContainsKey(champion));
			return Info[champion];
		}
Example #15
0
		public bool IsCastingSpell(ChampionTypes champ, PlayerActionType action)
		{
			SpellTypes spell = ChampionTypesHelper.GetSpellFromAction(champ, action);
			return TimeOfLastSpellUse(spell).TotalSeconds +
				SpellsHelper.Info(spell).CastingTime.TotalSeconds >= Server.Instance.GetTime().TotalSeconds;
		}
Example #16
0
 public ServerChampion(ulong id, Vec2 pos, ChampionTypes type, Teams team)
     : base(id, pos, type, team)
 {
 }
Example #17
0
		/// <summary>
		/// Adds the client to the current game.
		/// </summary>
		public void AddClient(NetConnection connection, ChampionTypes champ)
		{
			ILogger.Log("New player added to the game.", LogPriority.High);

			ServerChampion champion = CreateChampion(champ);
			ServerClient client = new ServerClient(connection, champion);

			// Send to the client that asked to join, along with the info of the current players
			List<ServerClient> remoteClients = new List<ServerClient>();
			foreach (ServerClient remote in Clients.Values) {
				remoteClients.Add(remote);
			}
			SendCommand(connection,
			            ServerCommand.JoinedGame,
			            NetDeliveryMethod.ReliableUnordered,
			            (msg) => FillJoinedGameMessage(msg, client, remoteClients));

			// Send the new player event to other players
			foreach (NetConnection clientConn in Clients.Keys) {
				if (clientConn != connection) {
					SendCommand(clientConn,
					           ServerCommand.NewRemotePlayer,
					           NetDeliveryMethod.ReliableUnordered,
					           (msg) => FillNewRemotePlayerMessage(msg, client));
				}
			}

			// Apply the changes to our game state
	        Clients.Add(connection, client);
	        Match.CurrentState.AddEntity(champion);
		}
Example #18
0
		/// <summary>
		/// Creates a champion.
		/// </summary>
		ServerChampion CreateChampion(ChampionTypes champ)
		{
			var team = GetSmallestTeam();
			return new ServerChampion(IDGenerator.GenerateID(),
			                          GetSpawnPosition(team),
			                          champ,
			                          team);
		}
Example #19
0
 public ChampionInfo GetInfo(ChampionTypes champion)
 {
     Debug.Assert(Info.ContainsKey(champion));
     return(Info[champion]);
 }
Example #20
0
		public void Display(ChampionTypes? killer, ChampionTypes? killed, bool FirstIsAlly) {
			Kill kill = new Kill(killer,killed,FirstIsAlly, ChampionsInfo);
			kill.Position = new Vector2(Kill.Width + ScreenOffset, 0);
			kill.Alpha = 0;
			KillsToBeAdded.Add(kill);
		}
Example #21
0
		public ServerChampion(ulong id, Vec2 pos, ChampionTypes type, Teams team)
			: base(id, pos, type, team)
        {
        }