예제 #1
0
		private void death(){
			if (attackTarget != null)
				attackTarget.SoldierDeath -= targetDied;
			GameOverlord.removeSoldierFromList (this, team);
			if (SoldierDeath != null)
				SoldierDeath.Invoke (this);
			Destroy (gameObject);
		}
예제 #2
0
        private static void activateAttack(Soldier s, float targetId, int team)
        {
            int     target        = (int)targetId;
            Soldier targetSoldier = GameOverlord.getEnemyList(team).Find(x => x.id == target);

            if (targetSoldier != null)
            {
                s.setAttackTarget(targetSoldier);
            }
        }
예제 #3
0
        void Awake()
        {
            singleton = this;
            spawnTeams(12, 77, 1, blueSoldier);
            spawnTeams(42, 77, 1, blueSoldier);
            spawnTeams(72, 77, 1, blueSoldier);

            spawnTeams(12, 20, 2, redSoldier);
            spawnTeams(42, 20, 2, redSoldier);
            spawnTeams(72, 20, 2, redSoldier);
        }
예제 #4
0
        public void startGame(List <ConnectedPlayer> players)
        {
            protocol     = gameMaster.protocol;
            gamePlaying  = true;
            this.players = players;
            team1        = GameOverlord.getEnemyList(2);
            team2        = GameOverlord.getEnemyList(1);
            StartCoroutine(updateGameStatus());


            allTeams.AddRange(team1);
            allTeams.AddRange(team2);
            broadcastBoard(new BoardUpdate(allTeams, new List <Soldier>(), 0, Time.time), true);
        }
예제 #5
0
		protected bool autoSelectTarget(){
			if (autoAttack == false)
				return false;
			
			agent.Resume ();
			List<Soldier> enemies = GameOverlord.getEnemyList (team);
			if (enemies.Count == 0)
				return false;
			enemies = enemies.OrderBy (x => Vector3.Distance (transform.position, x.transform.position)).ToList ();
			for (int i = 0; i < enemies.Count (); i++)
				if (enemies [i] != null) {
					setAttackTarget (enemies[i]);
					return true;
				}
			
			return false;
		}
예제 #6
0
        private static void activateCommand(TCPCommand command, int team)
        {
            List <Soldier> aliveSoldiers = GameOverlord.getEnemyList(team == 1 ? 2 : 1);

            //Could be optimized using dicts
            Soldier s = aliveSoldiers.Find(x => x.id == command.soldierId);

            if (s == null)
            {
                return;
            }


            switch (command.type)
            {
            case TCPCommandType.attack: activateAttack(s, command.followData[0], team); break;

            case TCPCommandType.autoAttack: s.startAutoAttack(); break;

            case TCPCommandType.move: activateMove(s, command.followData[0], command.followData[1]); break;
            }
        }
예제 #7
0
		// Use this for initialization

		public void init (int id, int team) {
			this.id = id;
			this.team = team;
			agent = GetComponent<NavMeshAgent> ();
			GameOverlord.addSoldierToList (this, team);
		}