コード例 #1
0
	// Use this for initialization
	public void setValues(GameObject sel, MeleeWeapon ownerWeap)
	{
		self = sel;
		wepCol = GetComponent<BoxCollider>();
		this.ownerWeap = ownerWeap;
		curTeam = sel.GetComponent<PlayerController>().team;
	}
コード例 #2
0
ファイル: Gun.cs プロジェクト: amacdiarmid/IP3-Project-RSSK
	void Start()
	{
		curAmmo = maxAmmo;
		gunAni = GetComponent<NetworkAnimator>();
		playCam = this.GetComponent<PlayerCamera>();
		if (gunAni == null)
			Debug.LogError ("Setup: Failed to find NetworkAnimator");
		curTeam = this.gameObject.GetComponent<PlayerController>().team;
	}
コード例 #3
0
ファイル: PlayerNode.cs プロジェクト: antonpup/CSGSI
 internal PlayerNode(string JSON)
     : base(JSON)
 {
     _SteamID = GetString("steamid");
     Name = GetString("name");
     Team = GetEnum<PlayerTeam>("team");
     Clan = GetString("clan");
     State = new PlayerStateNode(_Data?.SelectToken("state")?.ToString() ?? "{}");
     Weapons = new WeaponsNode(_Data?.SelectToken("weapons")?.ToString() ?? "{}");
     MatchStats = new MatchStatsNode(_Data?.SelectToken("match_stats")?.ToString() ?? "{}");
     Activity = GetEnum<PlayerActivity>("activity");
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: patchandthat/Dota2GSI
 internal Map(string json_data) : base(json_data)
 {
     Name = GetString("name");
     MatchID = GetInt("matchid");
     GameTime = GetInt("game_time");
     ClockTime = GetInt("clock_time");
     IsDaytime = GetBool("daytime");
     IsNightstalker_Night = GetBool("nightstalker_night");
     GameState = GetEnum<DOTA_GameState>("game_state");
     Win_team = GetEnum<PlayerTeam>("win_team");
     CustomGameName = GetString("customgamename");
     Ward_Purchase_Cooldown = GetInt("ward_purchase_cooldown");
 }
コード例 #5
0
ファイル: Player.cs プロジェクト: TylerStewart/Dota2GSI
 internal Player(string json_data) : base(json_data)
 {
     SteamID = GetString("steamid");
     Name = GetString("name");
     Activity = GetEnum<PlayerActivity>("activity");
     Kills = GetInt("kills");
     Deaths = GetInt("deaths");
     Assists = GetInt("assists");
     LastHits = GetInt("last_hits");
     Denies = GetInt("denies");
     KillStreak = GetInt("kill_streak");
     Team = GetEnum<PlayerTeam>("team_name");
     Gold = GetInt("gold");
     GoldReliable = GetInt("gold_reliable");
     GoldUnreliable = GetInt("gold_unreliable");
     GoldPerMinute = GetInt("gpm");
     ExperiencePerMinute = GetInt("xpm");
 }
コード例 #6
0
        public void Win( PlayerTeam team )
        {
            List<int> positions = new List<int>();

            // Set all to 2
            for (int i = 0; i < m_GlobalGameManager.PlayerCount; i++)
            {
                positions.Add(2);
            }

            // Set winning player positions to 0
            if (team == PlayerTeam.Team1)
            {
                positions[m_Team1.Players[0]] = 0;
                positions[m_Team1.Players[1]] = 0;
            }
            else
            {
                positions[m_Team2.Players[0]] = 0;
                positions[m_Team2.Players[1]] = 0;
            }

            m_GlobalGameManager.SubmitGameResults(positions);
        }
コード例 #7
0
        //dont forget duplicate function SetBlock
        public void SetBlockDebris(ushort x, ushort y, ushort z, BlockType blockType, PlayerTeam team)
        {
            if (x <= 0 || y <= 0 || z <= 0 || (int)x > MAPSIZE - 1 || (int)y > MAPSIZE - 1 || (int)z > MAPSIZE - 1)
                return;

            if (blockType == BlockType.None)//block removed, we must unsleep liquids nearby
            {
                Disturb(x, y, z);
            }

            blockListContent[x, y, z, 0] = 0;//dangerous stuff can happen if we dont set this

            if (blockType == BlockType.BeaconRed || blockType == BlockType.BeaconBlue)
            {
                Beacon newBeacon = new Beacon();
                newBeacon.ID = GenerateBeaconID();
                newBeacon.Team = blockType == BlockType.BeaconRed ? PlayerTeam.Red : PlayerTeam.Blue;
                beaconList[new Vector3(x, y, z)] = newBeacon;
                SendSetBeacon(new Vector3(x, y + 1, z), newBeacon.ID, newBeacon.Team);
            }
            else if (blockType == BlockType.Pipe)
            {
                blockListContent[x, y, z, 1] = 0;//Is pipe connected? [0-1]
                blockListContent[x, y, z, 2] = 0;//Is pipe a source? [0-1]
                blockListContent[x, y, z, 3] = 0;//Pipes connected
                blockListContent[x, y, z, 4] = 0;//Is pipe destination?
                blockListContent[x, y, z, 5] = 0;//src x
                blockListContent[x, y, z, 6] = 0;//src y
                blockListContent[x, y, z, 7] = 0;//src z
                blockListContent[x, y, z, 8] = 0;//pipe must not contain liquid
            }
            else if (blockType == BlockType.Barrel)
            {
                blockListContent[x, y, z, 1] = 0;//containtype
                blockListContent[x, y, z, 2] = 0;//amount
                blockListContent[x, y, z, 3] = 0;
            }
            else if (blockType == BlockType.Pump)
            {
                blockListContent[x, y, z, 1] = 0;//direction
                blockListContent[x, y, z, 2] = 0;//x input
                blockListContent[x, y, z, 3] = -1;//y input
                blockListContent[x, y, z, 4] = 0;//z input
                blockListContent[x, y, z, 5] = 0;//x output
                blockListContent[x, y, z, 6] = 1;//y output
                blockListContent[x, y, z, 7] = 0;//z output
            }

            if (blockType == BlockType.None && (blockList[x, y, z] == BlockType.BeaconRed || blockList[x, y, z] == BlockType.BeaconBlue))
            {
                if (beaconList.ContainsKey(new Vector3(x, y, z)))
                    beaconList.Remove(new Vector3(x, y, z));
                SendSetBeacon(new Vector3(x, y + 1, z), "", PlayerTeam.None);
            }

            if (blockType == blockList[x, y, z])//duplicate block, no need to send players data
            {
                blockList[x, y, z] = blockType;
                blockCreatorTeam[x, y, z] = team;
                flowSleep[x, y, z] = false;
            }
            else
            {

                blockList[x, y, z] = blockType;
                blockCreatorTeam[x, y, z] = team;
                flowSleep[x, y, z] = false;

                // x, y, z, type, all bytes
                NetBuffer msgBuffer = netServer.CreateBuffer();
                msgBuffer.Write((byte)InfiniminerMessage.BlockSetDebris);
                msgBuffer.Write((byte)x);
                msgBuffer.Write((byte)y);
                msgBuffer.Write((byte)z);
                if (blockType == BlockType.Vacuum)
                {
                    msgBuffer.Write((byte)BlockType.None);
                }
                else
                {
                    msgBuffer.Write((byte)blockType);
                }
                foreach (NetConnection netConn in playerList.Keys)
                    if (netConn.Status == NetConnectionStatus.Connected)
                        netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableUnordered);

            }
            //ConsoleWrite("BLOCKSET: " + x + " " + y + " " + z + " " + blockType.ToString());
        }
コード例 #8
0
        public void SendActiveArtifactUpdate(PlayerTeam team, int cc)
        {
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.ActiveArtifactUpdate);
            msgBuffer.Write((byte)team);
            msgBuffer.Write(cc);
            msgBuffer.Write(artifactActive[(byte)team,cc]);

            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected)
                    netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableInOrder1);
        }
コード例 #9
0
        public override void Spawn()
        {
            base.Spawn();

            // TODO
            idConsole.Warning("TODO: idActor.Spawn");

            /*
             * state = NULL;
             * idealState = NULL;*/

            _animPrefix = null;

            _rank                 = this.SpawnArgs.GetInteger("rank", 0);
            _team                 = (PlayerTeam)this.SpawnArgs.GetInteger("team", 0);
            _modelOffset          = this.SpawnArgs.GetVector3("offsetModel", Vector3.Zero);
            _useCombatBoundingBox = this.SpawnArgs.GetBool("use_combat_bbox", false);
            _viewAxis             = this.Physics.GetAxis();
            _finalBoss            = this.SpawnArgs.GetBool("finalBoss");

            _painDebounceTime = 0;
            _painDelay        = (int)(this.SpawnArgs.GetFloat("pain_delay") * 1000.0f);
            _painThreshold    = this.SpawnArgs.GetInteger("pain_threshold");

            this.Fov = this.SpawnArgs.GetFloat("fov", 90);

            /*LoadAF();
             *
             * walkIK.Init(this, IK_ANIM, modelOffset);
             *
             * // the animation used to be set to the IK_ANIM at this point, but that was fixed, resulting in
             * // attachments not binding correctly, so we're stuck setting the IK_ANIM before attaching things.
             * animator.ClearAllAnims(gameLocal.time, 0);
             * animator.SetFrame(ANIMCHANNEL_ALL, animator.GetAnim(IK_ANIM), 0, 0, 0);
             *
             * // spawn any attachments we might have
             * const idKeyValue* kv = spawnArgs.MatchPrefix("def_attach", NULL);
             * while(kv)
             * {
             *      idDict args;
             *
             *      args.Set("classname", kv->GetValue().c_str());
             *
             *      // make items non-touchable so the player can't take them out of the character's hands
             *      args.Set("no_touch", "1");
             *
             *      // don't let them drop to the floor
             *      args.Set("dropToFloor", "0");
             *
             *      gameLocal.SpawnEntityDef(args, &ent);
             *      if(!ent)
             *      {
             *              gameLocal.Error("Couldn't spawn '%s' to attach to entity '%s'", kv->GetValue().c_str(), name.c_str());
             *      }
             *      else
             *      {
             *              Attach(ent);
             *      }
             *      kv = spawnArgs.MatchPrefix("def_attach", kv);
             * }
             *
             * SetupDamageGroups();
             * SetupHead();
             *
             * // clear the bind anim
             * animator.ClearAllAnims(gameLocal.time, 0);
             *
             * idEntity* headEnt = head.GetEntity();
             * idAnimator* headAnimator;
             * if(headEnt)
             * {
             *      headAnimator = headEnt->GetAnimator();
             * }
             * else
             * {
             *      headAnimator = &animator;
             * }
             *
             * if(headEnt)
             * {
             *      // set up the list of joints to copy to the head
             *      for(kv = spawnArgs.MatchPrefix("copy_joint", NULL); kv != NULL; kv = spawnArgs.MatchPrefix("copy_joint", kv))
             *      {
             *              if(kv->GetValue() == "")
             *              {
             *                      // probably clearing out inherited key, so skip it
             *                      continue;
             *              }
             *
             *              jointName = kv->GetKey();
             *              if(jointName.StripLeadingOnce("copy_joint_world "))
             *              {
             *                      copyJoint.mod = JOINTMOD_WORLD_OVERRIDE;
             *              }
             *              else
             *              {
             *                      jointName.StripLeadingOnce("copy_joint ");
             *                      copyJoint.mod = JOINTMOD_LOCAL_OVERRIDE;
             *              }
             *
             *              copyJoint.from = animator.GetJointHandle(jointName);
             *              if(copyJoint.from == INVALID_JOINT)
             *              {
             *                      gameLocal.Warning("Unknown copy_joint '%s' on entity %s", jointName.c_str(), name.c_str());
             *                      continue;
             *              }
             *
             *              jointName = kv->GetValue();
             *              copyJoint.to = headAnimator->GetJointHandle(jointName);
             *              if(copyJoint.to == INVALID_JOINT)
             *              {
             *                      gameLocal.Warning("Unknown copy_joint '%s' on head of entity %s", jointName.c_str(), name.c_str());
             *                      continue;
             *              }
             *
             *              copyJoints.Append(copyJoint);
             *      }
             * }
             *
             * // set up blinking
             * blink_anim = headAnimator->GetAnim("blink");
             * blink_time = 0;	// it's ok to blink right away
             * blink_min = SEC2MS(spawnArgs.GetFloat("blink_min", "0.5"));
             * blink_max = SEC2MS(spawnArgs.GetFloat("blink_max", "8"));
             *
             * // set up the head anim if necessary
             * int headAnim = headAnimator->GetAnim("def_head");
             * if(headAnim)
             * {
             *      if(headEnt)
             *      {
             *              headAnimator->CycleAnim(ANIMCHANNEL_ALL, headAnim, gameLocal.time, 0);
             *      }
             *      else
             *      {
             *              headAnimator->CycleAnim(ANIMCHANNEL_HEAD, headAnim, gameLocal.time, 0);
             *      }
             * }
             *
             * if(spawnArgs.GetString("sound_bone", "", jointName))
             * {
             *      soundJoint = animator.GetJointHandle(jointName);
             *      if(soundJoint == INVALID_JOINT)
             *      {
             *              gameLocal.Warning("idAnimated '%s' at (%s): cannot find joint '%s' for sound playback", name.c_str(), GetPhysics()->GetOrigin().ToString(0), jointName.c_str());
             *      }
             * }*/

            FinishSetup();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Gigi220/TikTakToe
 public Player(Socket socket, PlayerTeam playerTeam)
 {
     Socket_ = socket;
     Team    = playerTeam;
 }
コード例 #11
0
 public void SendSetBeacon(Vector3 position, string text, PlayerTeam team)
 {
     NetBuffer msgBuffer = netServer.CreateBuffer();
     msgBuffer.Write((byte)InfiniminerMessage.SetBeacon);
     msgBuffer.Write(position);
     msgBuffer.Write(text);
     msgBuffer.Write((byte)team);
     foreach (NetConnection netConn in playerList.Keys)
         if (netConn.Status == NetConnectionStatus.Connected)
             netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableInOrder2);
 }
コード例 #12
0
 public TeamChangedEventArgs(PlayerTeam from, PlayerTeam to, Player player)
 {
     From   = from;
     To     = to;
     Player = player;
 }
コード例 #13
0
 /// <summary>
 /// Initializes the Player Class with a name and a team
 /// </summary>
 /// <param name="name">The name of the player</param>
 /// <param name="team">The Team of the player (PlayerTeam is defined in ITeam.cs)</param>
 public Player(string name, PlayerTeam team)
 {
     this.Name = name;
     this.Team = team;
 }
コード例 #14
0
 public void SetTeam(PlayerTeam team)
 {
     this.current_team = team;
 }
コード例 #15
0
    /// <summary>
    /// Arkadaş oyuncuların uzaklıklarına göre en uygun spawn noktaları hesaplanır.
    /// suitableSpawnPoints listesi nullsa oluşturulur ve temizlenir.
    /// Awakede elde edilen spawn noktaları (_sharedSpawnPoints) en yakın arkadaş uzaklıklarına göre küçükten büyüğe sıralanır.
    /// En yakın arkadaşa olan uzaklık _maxDistanceToClosestEnemy değerine küçük eşit olmak üzere, küçükten büyüğe sıralanmış olan spawn noktalarının arasından
    ///     -> en yakın arkadaş ve en yakın düşman uzaklıkları _minMemberDistance değerinden büyük ve
    ///     -> Timer'ı aktif olmayanlar (yani 2 sn içerisinde spawn yapılmamış olanlar)
    /// uygun spawn noktaları listesine eklenir. (suitableSpawnPoints)
    /// Eğer uygun spawn noktası bulunamadıysa _sharedSpawnPoints listesinde küçükten büyüğe sıralanmış noktalardan en küçüğü uygun nokta olarak alınır.
    /// </summary>

    private void GetSpawnPointsBySquadSpawning(PlayerTeam team, ref List <SpawnPoint> suitableSpawnPoints)
    {
        if (suitableSpawnPoints == null)
        {
            suitableSpawnPoints = new List <SpawnPoint>();
        }
        suitableSpawnPoints.Clear();
        _sharedSpawnPoints.Sort(delegate(SpawnPoint a, SpawnPoint b)
        {
            if (a.DistanceToClosestFriend == b.DistanceToClosestFriend)
            {
                return(0);
            }
            if (a.DistanceToClosestFriend > b.DistanceToClosestFriend)
            {
                return(1);
            }
            return(-1);
        });
        Debug.Log("Spawn noktaları arkadaş uzaklıklarına göre küçükten büyüğe sıralandı.\n       --Sorted Spawn Points-- ");
        _sharedSpawnPoints.ForEach(t => Debug.Log(t));

        for (int i = 0; i < _sharedSpawnPoints.Count && _sharedSpawnPoints[i].DistanceToClosestFriend <= _maxDistanceToClosestFriend; i++)
        {
            if (!(_sharedSpawnPoints[i].DistanceToClosestFriend <= _minMemberDistance) && !(_sharedSpawnPoints[i].DistanceToClosestEnemy <= _minMemberDistance) && _sharedSpawnPoints[i].SpawnTimer <= 0)
            {
                suitableSpawnPoints.Add(_sharedSpawnPoints[i]);
            }
        }

        //Spawn Noktalarının Hangisinin Neden Uygun olmadığı bilgisi için
        int control = 0;

        Debug.Log("NOT SUITABLE");
        for (int i = 0; i < _sharedSpawnPoints.Count; i++)
        {
            if (_sharedSpawnPoints[i].DistanceToClosestEnemy > _maxDistanceToClosestFriend)
            {
                Debug.Log(_sharedSpawnPoints[i] + "noktasına en yakın arkadaş uzaklığı _maxDistanceToClosestFriend= " + _maxDistanceToClosestFriend + "değerinden büyük olduğu için uygun değil"); control++;
            }
            if ((_sharedSpawnPoints[i].DistanceToClosestFriend <= _minMemberDistance) && (_sharedSpawnPoints[i].DistanceToClosestEnemy <= _minMemberDistance))
            {
                Debug.Log(_sharedSpawnPoints[i] + "noktasına en yakın oyuncu uzaklığı _minMemberDistance= " + _minMemberDistance + "değerinden küçük için uygun değil"); control++;
            }
            if (!(_sharedSpawnPoints[i].SpawnTimer <= 0))
            {
                Debug.Log(_sharedSpawnPoints[i] + "noktasının timerı sıfırlanmadı"); control++;
            }
        }
        if (control == 0)
        {
            Debug.Log("None");
        }
        Debug.Log(" SUITABLE");
        suitableSpawnPoints.ForEach(t => Debug.Log(t.ToString()));
        if (suitableSpawnPoints.Count <= 0)
        {
            Debug.Log("None");
        }

        Debug.Log("En yakın arkadaş uzaklıklarına göre spawn noktalarının en uygun olanları hesaplandı.\n");

        if (suitableSpawnPoints.Count <= 0)
        {
            Debug.Log("Uygun nokta bulunamadığından sıralanmış paylaşımlı spawn noktalarından ilki en uygun seçildi.\n");
            suitableSpawnPoints.Add(_sharedSpawnPoints[0]);
        }
    }
コード例 #16
0
        public void UpdateNetwork(GameTime gameTime)
        {
            // Update the server with our status.
            timeSinceLastUpdate += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceLastUpdate > 0.05)
            {
                timeSinceLastUpdate = 0;
                if (CurrentStateType == "Infiniminer.States.MainGameState")
                {
                    propertyBag.SendPlayerUpdate();
                }
            }

            // Recieve messages from the server.
            NetMessageType msgType;

            while (propertyBag.netClient.ReadMessage(msgBuffer, out msgType))
            {
                switch (msgType)
                {
                case NetMessageType.StatusChanged:
                {
                    if (propertyBag.netClient.Status == NetConnectionStatus.Disconnected)
                    {
                        ChangeState("Infiniminer.States.ServerBrowserState");
                    }
                }
                break;

                case NetMessageType.ConnectionRejected:
                {
                    string[] reason = msgBuffer.ReadString().Split(";".ToCharArray());
                    if (reason.Length < 2 || reason[0] == "VER")
                    {
                        MessageBox.Show("Error: client/server version incompability!\r\nServer: " + msgBuffer.ReadString() + "\r\nClient: " + INFINIMINER_VERSION);
                    }
                    else
                    {
                        MessageBox.Show("Error: you are banned from this server!");
                    }
                    ChangeState("Infiniminer.States.ServerBrowserState");
                }
                break;

                case NetMessageType.Data:
                {
                    InfiniminerMessage dataType = (InfiniminerMessage)msgBuffer.ReadByte();
                    switch (dataType)
                    {
                    case InfiniminerMessage.BlockBulkTransfer:
                    {
                        byte x = msgBuffer.ReadByte();
                        byte y = msgBuffer.ReadByte();
                        propertyBag.mapLoadProgress[x, y] = true;
                        for (byte dy = 0; dy < 16; dy++)
                        {
                            for (byte z = 0; z < 64; z++)
                            {
                                BlockType blockType = (BlockType)msgBuffer.ReadByte();
                                if (blockType != BlockType.None)
                                {
                                    propertyBag.blockEngine.downloadList[x, y + dy, z] = blockType;
                                }
                            }
                        }
                        bool downloadComplete = true;
                        for (x = 0; x < 64; x++)
                        {
                            for (y = 0; y < 64; y += 16)
                            {
                                if (propertyBag.mapLoadProgress[x, y] == false)
                                {
                                    downloadComplete = false;
                                    break;
                                }
                            }
                        }
                        if (downloadComplete)
                        {
                            ChangeState("Infiniminer.States.TeamSelectionState");
                            if (!NoSound)
                            {
                                MediaPlayer.Stop();
                            }
                            propertyBag.blockEngine.DownloadComplete();
                        }
                    }
                    break;

                    case InfiniminerMessage.SetBeacon:
                    {
                        Vector3    position = msgBuffer.ReadVector3();
                        string     text     = msgBuffer.ReadString();
                        PlayerTeam team     = (PlayerTeam)msgBuffer.ReadByte();

                        if (text == "")
                        {
                            if (propertyBag.beaconList.ContainsKey(position))
                            {
                                propertyBag.beaconList.Remove(position);
                            }
                        }
                        else
                        {
                            Beacon newBeacon = new Beacon();
                            newBeacon.ID   = text;
                            newBeacon.Team = team;
                            propertyBag.beaconList.Add(position, newBeacon);
                        }
                    }
                    break;

                    case InfiniminerMessage.TriggerConstructionGunAnimation:
                    {
                        propertyBag.constructionGunAnimation = msgBuffer.ReadFloat();
                        if (propertyBag.constructionGunAnimation <= -0.1)
                        {
                            propertyBag.PlaySound(InfiniminerSound.RadarSwitch);
                        }
                    }
                    break;

                    case InfiniminerMessage.ResourceUpdate:
                    {
                        // ore, cash, weight, max ore, max weight, team ore, red cash, blue cash, all uint
                        propertyBag.playerOre       = msgBuffer.ReadUInt32();
                        propertyBag.playerCash      = msgBuffer.ReadUInt32();
                        propertyBag.playerWeight    = msgBuffer.ReadUInt32();
                        propertyBag.playerOreMax    = msgBuffer.ReadUInt32();
                        propertyBag.playerWeightMax = msgBuffer.ReadUInt32();
                        propertyBag.teamOre         = msgBuffer.ReadUInt32();
                        propertyBag.teamRedCash     = msgBuffer.ReadUInt32();
                        propertyBag.teamBlueCash    = msgBuffer.ReadUInt32();
                    }
                    break;

                    case InfiniminerMessage.BlockSet:
                    {
                        // x, y, z, type, all bytes
                        byte      x         = msgBuffer.ReadByte();
                        byte      y         = msgBuffer.ReadByte();
                        byte      z         = msgBuffer.ReadByte();
                        BlockType blockType = (BlockType)msgBuffer.ReadByte();
                        if (blockType == BlockType.None)
                        {
                            if (propertyBag.blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                            {
                                propertyBag.blockEngine.RemoveBlock(x, y, z);
                            }
                        }
                        else
                        {
                            if (propertyBag.blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                            {
                                propertyBag.blockEngine.RemoveBlock(x, y, z);
                            }
                            propertyBag.blockEngine.AddBlock(x, y, z, blockType);
                            CheckForStandingInLava();
                        }
                    }
                    break;

                    case InfiniminerMessage.TriggerExplosion:
                    {
                        Vector3 blockPos = msgBuffer.ReadVector3();

                        // Play the explosion sound.
                        propertyBag.PlaySound(InfiniminerSound.Explosion, blockPos);

                        // Create some particles.
                        propertyBag.particleEngine.CreateExplosionDebris(blockPos);

                        // Figure out what the effect is.
                        float distFromExplosive = (blockPos + 0.5f * Vector3.One - propertyBag.playerPosition).Length();
                        if (distFromExplosive < 3)
                        {
                            propertyBag.KillPlayer("WAS KILLED IN AN EXPLOSION!");
                        }
                        else if (distFromExplosive < 8)
                        {
                            // If we're not in explosion mode, turn it on with the minimum ammount of shakiness.
                            if (propertyBag.screenEffect != ScreenEffect.Explosion)
                            {
                                propertyBag.screenEffect        = ScreenEffect.Explosion;
                                propertyBag.screenEffectCounter = 2;
                            }
                            // If this bomb would result in a bigger shake, use its value.
                            propertyBag.screenEffectCounter = Math.Min(propertyBag.screenEffectCounter, (distFromExplosive - 2) / 5);
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerSetTeam:
                    {
                        uint playerId = msgBuffer.ReadUInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            Player player = propertyBag.playerList[playerId];
                            player.Team = (PlayerTeam)msgBuffer.ReadByte();
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerJoined:
                    {
                        uint   playerId    = msgBuffer.ReadUInt32();
                        string playerName  = msgBuffer.ReadString();
                        bool   thisIsMe    = msgBuffer.ReadBoolean();
                        bool   playerAlive = msgBuffer.ReadBoolean();
                        propertyBag.playerList[playerId]        = new Player(null, (Game)this);
                        propertyBag.playerList[playerId].Handle = playerName;
                        propertyBag.playerList[playerId].ID     = playerId;
                        propertyBag.playerList[playerId].Alive  = playerAlive;
                        if (thisIsMe)
                        {
                            propertyBag.playerMyId = playerId;
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerLeft:
                    {
                        uint playerId = msgBuffer.ReadUInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            propertyBag.playerList.Remove(playerId);
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerDead:
                    {
                        uint playerId = msgBuffer.ReadUInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            Player player = propertyBag.playerList[playerId];
                            player.Alive = false;
                            propertyBag.particleEngine.CreateBloodSplatter(player.Position, player.Team == PlayerTeam.Red ? Color.Red : Color.Blue);
                            if (playerId != propertyBag.playerMyId)
                            {
                                propertyBag.PlaySound(InfiniminerSound.Death, player.Position);
                            }
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerAlive:
                    {
                        uint playerId = msgBuffer.ReadUInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            Player player = propertyBag.playerList[playerId];
                            player.Alive = true;
                        }
                    }
                    break;

                    case InfiniminerMessage.PlayerUpdate:
                    {
                        uint playerId = msgBuffer.ReadUInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            Player player = propertyBag.playerList[playerId];
                            player.UpdatePosition(msgBuffer.ReadVector3(), gameTime.TotalGameTime.TotalSeconds);
                            player.Heading   = msgBuffer.ReadVector3();
                            player.Tool      = (PlayerTools)msgBuffer.ReadByte();
                            player.UsingTool = msgBuffer.ReadBoolean();
                            player.Score     = (uint)(msgBuffer.ReadUInt16() * 100);
                        }
                    }
                    break;

                    case InfiniminerMessage.GameOver:
                    {
                        propertyBag.teamWinners = (PlayerTeam)msgBuffer.ReadByte();
                    }
                    break;

                    case InfiniminerMessage.ChatMessage:
                    {
                        ChatMessageType chatType   = (ChatMessageType)msgBuffer.ReadByte();
                        string          chatString = msgBuffer.ReadString();
                        ChatMessage     chatMsg    = new ChatMessage(chatString, chatType, 10);
                        propertyBag.chatBuffer.Insert(0, chatMsg);
                        propertyBag.PlaySound(InfiniminerSound.ClickLow);
                    }
                    break;

                    case InfiniminerMessage.PlayerPing:
                    {
                        uint playerId = (uint)msgBuffer.ReadInt32();
                        if (propertyBag.playerList.ContainsKey(playerId))
                        {
                            if (propertyBag.playerList[playerId].Team == propertyBag.playerTeam)
                            {
                                propertyBag.playerList[playerId].Ping = 1;
                                propertyBag.PlaySound(InfiniminerSound.Ping);
                            }
                        }
                    }
                    break;

                    case InfiniminerMessage.PlaySound:
                    {
                        InfiniminerSound sound       = (InfiniminerSound)msgBuffer.ReadByte();
                        bool             hasPosition = msgBuffer.ReadBoolean();
                        if (hasPosition)
                        {
                            Vector3 soundPosition = msgBuffer.ReadVector3();
                            propertyBag.PlaySound(sound, soundPosition);
                        }
                        else
                        {
                            propertyBag.PlaySound(sound);
                        }
                    }
                    break;
                    }
                }
                break;
                }
            }

            // Make sure our network thread actually gets to run.
            Thread.Sleep(1);
        }
コード例 #17
0
    public static CampPlaceMarcation GetPlaceMarcation(this PlayerController controller)
    {
        PlayerTeam pinput = controller.GetComponent <PlayerTeam>();

        return(pinput.PlaceMarcation);
    }
コード例 #18
0
    public static CampActionAttribute GetCampAction(this PlayerController controller)
    {
        PlayerTeam pinput = controller.GetComponent <PlayerTeam>();

        return(pinput.PlaceAction);
    }
コード例 #19
0
    public static CampTeam GetCampTeam(this PlayerController controller)
    {
        PlayerTeam pinput = controller.GetComponent <PlayerTeam>();

        return(pinput.Team);
    }
コード例 #20
0
        public uint SetItem(ItemType iType, Vector3 pos, Vector3 heading, Vector3 vel, PlayerTeam team, int val)
        {
            if(iType == ItemType.Gold || iType == ItemType.Ore)//merge minerals on the ground
            foreach (KeyValuePair<uint, Item> iF in itemList)//pretty inefficient
            {
                    if (Distf(pos, iF.Value.Position) < 2.0f)
                    {
                        if (iType == iF.Value.Type && !iF.Value.Disposing && iF.Value.Content[5] < 10)//limit stacks to 10
                        {
                            iF.Value.Content[5] += 1;//supposed ore content
                            iF.Value.Scale = 0.5f + (float)(iF.Value.Content[5]) * 0.1f;
                            SendItemScaleUpdate(iF.Value);
                            return iF.Key;//item does not get created, instead merges
                        }
                    }
            }

                Item newItem = new Item(null, iType);
                newItem.ID = GenerateItemID();
                newItem.Team = team;
                newItem.Heading = heading;
                newItem.Position = pos;
                newItem.Velocity = vel;

                if (iType == ItemType.Artifact)
                {
                    newItem.Content[10] = val;
                    if (newItem.Content[10] == 0)//undefined artifact, give it a random color
                    {
                        newItem.Content[1] = (int)(randGen.NextDouble() * 100);//r
                        newItem.Content[2] = (int)(randGen.NextDouble() * 100);//g
                        newItem.Content[3] = (int)(randGen.NextDouble() * 100);//b
                    }
                    else if (newItem.Content[10] == 1)//material artifact: generates 10 ore periodically
                    {
                        newItem.Content[1] = (int)(0.6 * 100);//r
                        newItem.Content[2] = (int)(0.6 * 100);//g
                        newItem.Content[3] = (int)(0.6 * 100);//b
                    }
                    else if (newItem.Content[10] == 2)//vampiric artifact
                    {
                        newItem.Content[1] = (int)(0.5 * 100);//r
                        newItem.Content[2] = (int)(0.1 * 100);//g
                        newItem.Content[3] = (int)(0.1 * 100);//b
                    }
                    else if (newItem.Content[10] == 3)//regeneration artifact
                    {
                        newItem.Content[1] = (int)(0.3 * 100);//r
                        newItem.Content[2] = (int)(0.9 * 100);//g
                        newItem.Content[3] = (int)(0.3 * 100);//b
                    }
                    else if (newItem.Content[10] == 4)//aqua artifact: personal: gives waterbreathing, waterspeed and digging underwater, team: gives team water breathing and ability to dig underwater
                    {
                        newItem.Content[1] = (int)(0.5 * 100);//r
                        newItem.Content[2] = (int)(0.5 * 100);//g
                        newItem.Content[3] = (int)(0.8 * 100);//b
                    }
                    else if (newItem.Content[10] == 5)//golden artifact: personal: converts ore to gold, team: generates gold slowly
                    {
                        newItem.Content[1] = (int)(0.87 * 100);//r
                        newItem.Content[2] = (int)(0.71 * 100);//g
                        newItem.Content[3] = (int)(0.25 * 100);//b
                    }
                    else if (newItem.Content[10] == 6)//storm artifact: ground: creates water in empty spaces, personal: periodically shocks opponents, team:
                    {
                        newItem.Content[1] = (int)(0.1 * 100);//r
                        newItem.Content[2] = (int)(0.4 * 100);//g
                        newItem.Content[3] = (int)(0.9 * 100);//b
                    }
                    else if (newItem.Content[10] == 7)//reflection artifact: ground: repels bombs, personal: reflects half damage, team:
                    {
                        newItem.Content[1] = (int)(0.3 * 100);//r
                        newItem.Content[2] = (int)(0.3 * 100);//g
                        newItem.Content[3] = (int)(0.3 * 100);//b
                    }
                    else if (newItem.Content[10] == 8)//medical artifact: ground: heals any players nearby, personal: allows player to hit friendlies to heal them, team:
                    {
                        newItem.Content[1] = (int)(0.1 * 100);//r
                        newItem.Content[2] = (int)(1.0 * 100);//g
                        newItem.Content[3] = (int)(0.1 * 100);//b
                    }
                    else if (newItem.Content[10] == 9)//stone artifact: ground: causes blocks to fall that arent attached to similar types, personal: immune to knockback, team: reduces knockback
                    {
                        newItem.Content[1] = (int)(0.9 * 100);//r
                        newItem.Content[2] = (int)(0.7 * 100);//g
                        newItem.Content[3] = (int)(0.7 * 100);//b
                    }
                }
                else if (iType == ItemType.Bomb)
                {
                    newItem.Content[1] = 100;//r
                    newItem.Content[2] = 100;//g
                    newItem.Content[3] = 100;//b
                    newItem.Content[5] = 80;//4 second fuse
                    newItem.Weight = 1.5f;
                }
                else if (iType == ItemType.Rope)
                {
                    newItem.Content[1] = 100;//r
                    newItem.Content[2] = 100;//g
                    newItem.Content[3] = 100;//b
                    newItem.Weight = 0.6f;
                }
                else
                {
                    newItem.Content[1] = 100;//r
                    newItem.Content[2] = 100;//g
                    newItem.Content[3] = 100;//b
                }

                itemList[newItem.ID] = newItem;
                SendSetItem(newItem.ID, newItem.Type, newItem.Position, newItem.Team, newItem.Heading);
                return newItem.ID;
        }
コード例 #21
0
        public void VictoryCheck()
        {
            //foreach (Player p in playerList.Values)
            //{
              //  if (p.Position.Y > 64 - Defines.GROUND_LEVEL)
             //       DepositCash(p);
               // }

            if (varGetB("sandbox"))
                return;
            if (teamArtifactsBlue >= winningCashAmount && winningTeam == PlayerTeam.None)
                winningTeam = PlayerTeam.Blue;
            if (teamArtifactsRed >= winningCashAmount && winningTeam == PlayerTeam.None)
                winningTeam = PlayerTeam.Red;
        }
コード例 #22
0
ファイル: PlayerCtrl.cs プロジェクト: gugugames/Icy-Inky-Road
 public void ChangeColorB()
 {
     playerTeam = PlayerTeam.B;
     transform.Find("Particle System").GetComponent <ParticlePainter>().brush.splatChannel = 1;
     GetComponent <Renderer>().material.color = new Color(0, 0, 255);
 }
コード例 #23
0
 public Terrain(Trainer adversaire, PlayerTeam me)
 {
     this.adversaire = adversaire;
     this.me         = me;
     callPokemon();
 }
コード例 #24
0
ファイル: GameOver.cs プロジェクト: Qazzquimby/Unreal300Bot
 public GameOverArgs(PlayerTeam winningteam)
 {
     WinningTeam = winningteam;
 }
コード例 #25
0
        public void DepositForPlayers()
        {
            foreach (Player p in playerList.Values)
            {
                if (p.Position.Y > 64 - Defines.GROUND_LEVEL)
                    DepositCash(p);
            }

            if (varGetB("sandbox"))
                return;
            if (teamCashBlue >= winningCashAmount && winningTeam == PlayerTeam.None)
                winningTeam = PlayerTeam.Blue;
            if (teamCashRed >= winningCashAmount && winningTeam == PlayerTeam.None)
                winningTeam = PlayerTeam.Red;
        }
コード例 #26
0
ファイル: MorotVsIhmiset.cs プロジェクト: juherask/sejypeli
    void OnDeploy(PlayerTeam team, int pathIndex)
    {
        // Disable deploy buttons
        foreach (var button in teams[team].DeployButtons.Values)
        {
            // Already disabled, cannot deploy!
            if (button.Color == Color.LightGray)
                return;

            button.Color = Color.LightGray;
        }

        // Deploy the first unit
        PhysicsObject unitToDeploy = teams[team].DeployQueue.First.Value;
        teams[team].DeployQueue.RemoveFirst();

        ProgressDeployQueue(team);

        // Check that is not already fleeing
        if (!unitToDeploy.IgnoresCollisionResponse)
        {
            // determine in which turn to traverse the path
            int segmentIndex = 1;
            if (team == PlayerTeam.Monsters)
                segmentIndex = paths[pathIndex].Segments.Length - 2;
            OnMoveUnit(unitToDeploy, segmentIndex, paths[pathIndex]);
        }
    }
コード例 #27
0
    //Translate all the data send by the server
    private void TranslateData(string[] allCommands)
    {
        foreach (string command in allCommands)
        {
            string[] commandParts = command.Split();

            switch ((ServerMessage)int.Parse(commandParts[0]))
            {
            //Sets the angle of the other players.
            case ServerMessage.SetPlayerAngle:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.SetAngle(id, commandParts);
                }
            }
            break;

            //Sets the position of the players
            case ServerMessage.SetPlayerPosition:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.SetPosition(id, commandParts);
                }
                else
                {
                    localPlayer.SetPos(commandParts);
                    localPlayer.Reconcile();
                }
            }
            break;

            //Set the last command processed by the server
            case ServerMessage.LastCommandProcessed:
            {
                localPlayer.LastCommandProccesed =
                    uint.Parse(commandParts[1]);
                break;
            }

            //Adds a new bullet
            case ServerMessage.NewBullet:
            {
                bullets.Add(commandParts);
            }
            break;

            //Removes a bullet
            case ServerMessage.RemoveBullet:
            {
                bullets.Remove(commandParts);
            }
            break;

            //Damages the local player
            case ServerMessage.DamagePlayer:
            {
                localPlayer.TakeDamage(commandParts);
            }
            break;

            //Respawns a player
            case ServerMessage.Respawn:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.Respawn(id, commandParts);
                }
                else
                {
                    localPlayer.Respawn(commandParts);
                    CurrentUpdateGameFunction = UpdateGameStateAlive;
                    CurrentRenderGameFunction = RenderGameAlive;
                }
            }
            break;

            //Kills the player
            case ServerMessage.KillPlayer:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.Kill(id);
                }
                else
                {
                    localPlayer.Kill();
                    CurrentUpdateGameFunction = UpdateGameStateDead;
                    CurrentRenderGameFunction = RenderGameDead;
                }
            }
            break;

            case ServerMessage.NewRound:
            {
                winnerTeam = (PlayerTeam)
                             int.Parse(commandParts[1]);
                if (winnerTeam != PlayerTeam.Spectator)
                {
                    isNewRound      = true;
                    winnerTextTimer = SDL.SDL_GetTicks();
                }
                break;
            }

            //Changes the team of a player
            case ServerMessage.SetPlayerTeam:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.SetTeam(id, commandParts);
                }
                else
                {
                    localPlayer.SetTeam(commandParts);

                    if ((PlayerTeam)int.Parse(commandParts[2])
                        == PlayerTeam.Spectator)
                    {
                        CurrentUpdateGameFunction
                            = UpdateGameStateSpectator;
                    }

                    else
                    {
                        CurrentUpdateGameFunction
                            = UpdateGameStateDead;
                    }
                }
            }
            break;

            //Creates a new player
            case ServerMessage.NewPlayer:
            {
                int id = int.Parse(commandParts[1]);
                if (id != localPlayer.ID)
                {
                    players.Add(id, commandParts);
                }
                break;
            }

            //Removes a player
            case ServerMessage.RemovePlayer:
            {
                int id = int.Parse(commandParts[1]);
                players.Remove(id);
            }
            break;

            //Disconnects a player
            case ServerMessage.Disconnect:
                NextScreen      = ScreenType.End;
                Game.EndMessage = Game.LanguageTranslation
                                  [Game.GameLanguage + commandParts[1]];
                Game.GameSocket.Disconnect();
                break;

            //Sets the id of the local player.
            case ServerMessage.SetID:
                localPlayer.ID = int.Parse(commandParts[1]);
                break;
            }
        }
    }
コード例 #28
0
ファイル: MorotVsIhmiset.cs プロジェクト: juherask/sejypeli
    void OnOperateTree(PhysicsObject tree, Image newState, PhysicsObject unitToQueue, PlayerTeam team)
    {
        if (newState == saplingImage && tree.Image != saplingImage)
            Timer.SingleShot(treeGrowsTime, () => tree.Image = treeImage);
        if (newState == logImage && tree.Image != logImage)
            Timer.SingleShot(treeGrowsTime, () => { if (tree.Image == logImage) tree.Image = stumpImage; });

        tree.Image = newState;

        double resources = 0.0;
        if (unitToQueue.Image == mGatherer || unitToQueue.Image == mGatherer)
        {
            resources = amountPerResource;
        }

        // Unit reuse
        MoveToDeployQueue(team, unitToQueue, resources);
    }
コード例 #29
0
        public void SetPath(Squad squad)
        {
            Team     = squad.Team;
            AllTiles = squad
                       .GetParent <Player>()
                       .GetParent()
                       .GetNode("Board")
                       .GetNode <Node2D>("TilesCollection");
            Path = new List <KeyValuePair <Tile, SoldierTenure> >();

            var teamString  = Team.ToString();
            var otherString = Team == PlayerTeam.White ? "Black" : "White";

            if (AllTiles == null)
            {
                return;
            }
            // starting line
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Start") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Road") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Camp") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Temple") as Tile,
                    SoldierTenure.Private));

            // middle line
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Finish") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("MainRoad") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Uruk") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("MainTemple") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("BridgeRoad") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("BridgeCity") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("BridgeCamp") as Tile,
                    SoldierTenure.Private));

            // after bridge
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Temple2") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(teamString + "Pyramid") as Tile,
                    SoldierTenure.Private));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Battleground") as Tile,
                    SoldierTenure.Switch));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(otherString + "Pyramid") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode(otherString + "Temple2") as Tile,
                    SoldierTenure.Veteran));

            // finish line
            Path.Add(new KeyValuePair <Tile, SoldierTenure>(
                         AllTiles.GetNode("BridgeCamp") as Tile,
                         SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("BridgeCity") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("BridgeRoad") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("MainTemple") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Uruk") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("MainRoad") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Finish") as Tile,
                    SoldierTenure.Veteran));
            Path.Add(
                new KeyValuePair <Tile, SoldierTenure>(
                    AllTiles.GetNode("Release") as Tile,
                    SoldierTenure.Veteran));
        }
コード例 #30
0
ファイル: MorotVsIhmiset.cs プロジェクト: juherask/sejypeli
    void OnResourceAdded(PlayerTeam team, double amount, bool trickle)
    {
        foreach (var kvp in teams[team].UnitCreationProgress)
        {
            double portion = amount * (teams[team].UnitCreationAllocation[kvp.Key].Value / 100.0);
            kvp.Value.AddValue(portion);
        }

        if (trickle)
            Timer.SingleShot(trickleRate, () => OnResourceAdded(team, resourcesTrickleAmount, true));
    }
コード例 #31
0
        public void ResearchRecalculate(PlayerTeam team, int cc)
        {
            if (cc == 1)//modifying maximum hp
            {
                foreach (Player p in playerList.Values)
                    if (p.Team == team)
                    {
                        p.HealthMax += 20;// (uint)(ResearchComplete[(byte)team, cc] * 20);
                        SendResourceUpdate(p);
                    }
            }
            else if (cc == 2)
            {
                foreach (Player p in playerList.Values)
                    if (p.Team == team)
                    {
                        p.WeightMax += 1;// (uint)(ResearchComplete[(byte)team, cc]);
                        p.OreMax += 20;// (uint)(ResearchComplete[(byte)team, cc] * 20);
                        SendResourceUpdate(p);
                    }
            }
            else if (cc == 3)
            {
                teamRegeneration[(byte)team]++;
            }

               // SendResourceUpdate(p);
        }
コード例 #32
0
ファイル: MorotVsIhmiset.cs プロジェクト: juherask/sejypeli
    void ProgressDeployQueue(PlayerTeam team)
    {
        // Progress the queue
        if (teams[team].DeployQueue.Count > 0)
        {
            Vector moveToPos = Vector.Zero;
            PhysicsObject moveUnit = null;
            for (int i = 0; i < teams[team].DeployQueue.Count; i++)
            {
                moveToPos = GatherPoints[team] + new Vector(
                     40 * i,
                     Math.Min(1,i) * (team == PlayerTeam.Humans ? 40 : -40) );

                moveUnit = teams[team].DeployQueue.ElementAt(i);
                if (i == 0)
                {
                    Action afterMove = () => OnCanDeploy(team);
                    moveUnit.MoveTo(moveToPos, unitMoveSpeed, afterMove);
                    moveOrStayTarget[moveUnit] = new Tuple<Vector, Action>(moveToPos, afterMove);
                }
                else
                {
                    moveUnit.MoveTo(moveToPos, unitMoveSpeed);
                    moveOrStayTarget[moveUnit] = new Tuple<Vector, Action>(moveToPos, null);
                }
            }
        }
    }
コード例 #33
0
        //update player joined also
        public void SendSetItem(uint id, ItemType iType, Vector3 position, PlayerTeam team, Vector3 heading)
        {
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.SetItem);
            msgBuffer.Write((byte)iType);
            msgBuffer.Write(id);
            msgBuffer.Write(position);
            msgBuffer.Write((byte)team);
            msgBuffer.Write(heading);
            msgBuffer.Write(itemList[id].Content[1]);
            msgBuffer.Write(itemList[id].Content[2]);
            msgBuffer.Write(itemList[id].Content[3]);
            msgBuffer.Write(itemList[id].Content[10]);

            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected)
                    netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableInOrder2);
        }
コード例 #34
0
ファイル: Score.cs プロジェクト: cvayer/Belote-Unity
 public int GetScore(PlayerTeam team)
 {
     return(m_scores[(int)team]);
 }
コード例 #35
0
        public void SetBlockForPlayer(ushort x, ushort y, ushort z, BlockType blockType, PlayerTeam team, Player player)
        {
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.BlockSet);
            msgBuffer.Write((byte)x);
            msgBuffer.Write((byte)y);
            msgBuffer.Write((byte)z);

            if (blockType == BlockType.Vacuum)
            {
                msgBuffer.Write((byte)BlockType.None);
            }
            else
            {
                msgBuffer.Write((byte)blockType);
            }

            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected)
                {
                    if (playerList[netConn] == player)
                    {
                        netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableUnordered);
                        return;
                    }
                }
        }
コード例 #36
0
ファイル: Score.cs プロジェクト: cvayer/Belote-Unity
 public void AddScore(PlayerTeam team, int score)
 {
     m_scores[(int)team] += score;
 }
コード例 #37
0
        public void BombAtPoint(int x, int y, int z, PlayerTeam team)
        {
            ExplosionEffectAtPoint(x, y, z, 3, team);

            for (int dx = -1; dx <= 1; dx++)
                for (int dy = -1; dy <= 1; dy++)
                    for (int dz = -1; dz <= 1; dz++)
                    {
                        if (x + dx <= 0 || y + dy <= 0 || z + dz <= 0 || x + dx > MAPSIZE - 1 || y + dy > MAPSIZE - 1 || z + dz > MAPSIZE - 1)
                            continue;

                        if (blockList[x + dx, y + dy, z + dz] == BlockType.Explosive)
                            if (blockCreatorTeam[x + dx, y + dy, z + dz] != team)//must hit opposing team
                                DetonateAtPoint(x + dx, y + dy, z + dz);

                        if(BlockInformation.GetMaxHP(blockList[x + dx, y + dy, z + dz]) > 0)//not immune block
                            if (blockCreatorTeam[x + dx, y + dy, z + dz] != team)//must hit opposing team
                        if (blockListHP[x + dx, y + dy, z + dz] > 0)
                        {

                            if (blockList[x + dx, y + dy, z + dz] == BlockType.Gold || blockList[x + dx, y + dy, z + dz] == BlockType.Diamond)
                            {//these blocks immune to explosives

                            }
                            else
                            {

                                blockListHP[x + dx, y + dy, z + dz] -= 10;

                                if (blockListHP[x + dx, y + dy, z + dz] <= 0)
                                {
                                    blockListHP[x + dx, y + dy, z + dz] = 0;
                                    if (blockList[x + dx, y + dy, z + dz] == BlockType.RadarRed)//requires special remove
                                    {
                                        foreach (Player p in playerList.Values)
                                        {
                                            if (p.Alive && p.Team == PlayerTeam.Blue)
                                            {
                                                if (p.Content[1] == 1)
                                                {
                                                    p.Content[1] = 0;//goes off radar again
                                                    SendPlayerContentUpdate(p, 1);
                                                }
                                            }
                                        }
                                    }
                                    else if (blockList[x + dx, y + dy, z + dz] == BlockType.RadarBlue)//requires special remove
                                    {
                                        foreach (Player p in playerList.Values)
                                        {
                                            if (p.Alive && p.Team == PlayerTeam.Red)
                                            {
                                                if (p.Content[1] == 1)
                                                {
                                                    p.Content[1] = 0;//goes off radar again
                                                    SendPlayerContentUpdate(p, 1);
                                                }
                                            }
                                        }
                                    }
                                    else if (blockList[x + dx, y + dy, z + dz] == BlockType.Ore)
                                    {//item creation must be outside item loop
                                        SetItem(ItemType.Ore, new Vector3(x, y, z), Vector3.Zero, Vector3.Zero, PlayerTeam.None, 0);
                                    }

                                    SetBlockDebris((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz), BlockType.None, PlayerTeam.None);
                                }
                                else
                                {
                                    if (blockList[x + dx, y + dy, z + dz] == BlockType.Rock)//rock is weak to explosives
                                    {//item creation must be outside item loop
                                        SetBlockDebris((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz), BlockType.None, PlayerTeam.None);
                                    }
                                }
                            }
                        }
                    }
        }
コード例 #38
0
 public void Deserialize(byte[] data)
 {
     Text     = PacketSerializationTools.GetString(data, 0);
     Position = PacketSerializationTools.GetVector3(data, Text.Length + 1);
     Team     = (PlayerTeam)data[data.Length - 1];
 }
コード例 #39
0
        public void createBase(PlayerTeam team)
        {
            int pos = randGen.Next(10, 50);
            int posy = 61 - randGen.Next(10, 20);

            if(team == PlayerTeam.Red)
            {
                for (int a = -10; a < 10; a++)
                    for (int b = -3; b < 3; b++)
                        for (int c = -10; c < 10; c++)//clear rock
                        {
                            if (blockList[pos + a, posy + b, 50 + c] == BlockType.Rock)
                            {
                                blockList[pos + a, posy + b, 50 + c] = BlockType.Dirt;
                            }
                        }

                for (int a = -3; a < 3; a++)
                    for (int b = -2; b < 3; b++)
                        for (int c = -3; c < 3; c++)//place outer shell
                        {
                            blockList[pos + a, posy + b, 50 + c] = BlockType.SolidRed2;
                            blockListHP[pos + a, posy + b, 50 + c] = 400;
                            blockCreatorTeam[pos + a, posy + b, 50 + c] = PlayerTeam.None;
                        }

                for (int a = -2; a < 2; a++)
                    for (int b = -1; b < 2; b++)
                        for (int c = -2; c < 2; c++)//prevent players from adding stuff to it
                        {
                            blockList[pos + a, posy + b, 50 + c] = BlockType.Vacuum;
                        }

                blockList[pos, posy - 1, 50 - 3] = BlockType.TransRed;
                blockList[pos, posy, 50 - 3] = BlockType.TransRed;
                blockList[pos-1, posy - 1, 50 - 3] = BlockType.TransRed;
                blockList[pos-1, posy, 50 - 3] = BlockType.TransRed;

                blockList[pos, posy - 1, 50 - 4] = BlockType.None;
                blockList[pos, posy, 50 - 4] = BlockType.None;
                blockList[pos - 1, posy - 1, 50 - 4] = BlockType.None;
                blockList[pos - 1, posy, 50 - 4] = BlockType.None;

                RedBase = new PlayerBase();
                basePosition.Add(PlayerTeam.Red,RedBase);
                basePosition[PlayerTeam.Red].team = PlayerTeam.Red;
                basePosition[PlayerTeam.Red].X = pos;
                basePosition[PlayerTeam.Red].Y = posy;
                basePosition[PlayerTeam.Red].Z = 50;
                blockList[pos - 2, posy - 1, 51] = BlockType.BaseRed;
                //SetBlock((ushort)(pos - 2), (ushort)(posy - 1), 50, BlockType.BeaconRed, PlayerTeam.Red);
                blockList[pos - 2, posy - 1, 49] = BlockType.BankRed;

                Beacon newBeacon = new Beacon();
                newBeacon.ID = "HOME";
                newBeacon.Team = PlayerTeam.Red;
                beaconList[new Vector3(pos - 2, posy - 1, 50)] = newBeacon;
                SendSetBeacon(new Vector3(pos - 2, posy, 50), newBeacon.ID, newBeacon.Team);
            }
            else
            {
                for (int a = -10; a < 10; a++)
                    for (int b = -3; b < 3; b++)
                        for (int c = -10; c < 10; c++)
                        {
                            if (blockList[pos + a, posy + b, 14 + c] == BlockType.Rock)
                            {
                                blockList[pos + a, posy + b, 14 + c] = BlockType.Dirt;
                            }
                        }

                for (int a = -3; a < 3; a++)
                    for (int b = -3; b < 3; b++)
                        for (int c = -3; c < 3; c++)
                        {
                            blockList[pos + a, posy + b, 14 + c] = BlockType.SolidBlue2;
                            blockListHP[pos + a, posy + b, 14 + c] = 400;
                            blockCreatorTeam[pos + a, posy + b, 14 + c] = PlayerTeam.None;
                        }

                for (int a = -2; a < 2; a++)
                    for (int b = -1; b < 2; b++)
                        for (int c = -2; c < 2; c++)
                        {
                            blockList[pos + a, posy + b, 14 + c] = BlockType.Vacuum;
                        }

                blockList[pos, posy - 1, 14 + 2] = BlockType.TransBlue;
                blockList[pos, posy, 14 + 2] = BlockType.TransBlue;
                blockList[pos - 1, posy - 1, 14 + 2] = BlockType.TransBlue;
                blockList[pos - 1, posy, 14 + 2] = BlockType.TransBlue;

                blockList[pos, posy - 1, 14 + 3] = BlockType.None;
                blockList[pos, posy, 14 + 3] = BlockType.None;
                blockList[pos - 1, posy - 1, 14 + 3] = BlockType.None;
                blockList[pos - 1, posy, 14 + 3] = BlockType.None;

                BlueBase = new PlayerBase();
                basePosition.Add(PlayerTeam.Blue,BlueBase);
                basePosition[PlayerTeam.Blue].team = PlayerTeam.Blue;
                basePosition[PlayerTeam.Blue].X = pos;
                basePosition[PlayerTeam.Blue].Y = posy;
                basePosition[PlayerTeam.Blue].Z = 14;
                blockList[pos-2, posy-1, 13] = BlockType.BaseBlue;
                blockList[pos-2, posy-1, 15] = BlockType.BankBlue;
                //SetBlock((ushort)(pos - 2), (ushort)(posy - 1), 14, BlockType.BeaconBlue, PlayerTeam.Blue);
                Beacon newBeacon = new Beacon();
                newBeacon.ID = "HOME";
                newBeacon.Team = PlayerTeam.Blue;
                beaconList[new Vector3(pos - 2, posy - 1, 14)] = newBeacon;
                SendSetBeacon(new Vector3(pos - 2, posy, 14), newBeacon.ID, newBeacon.Team);
            }
        }
コード例 #40
0
 public void AddPlayer(PlayerTeam newTeam)
 {
     s_teams.Add(newTeam);
 }
コード例 #41
0
 /// <summary>
 /// Gets all players that are on the specified team.
 /// </summary>
 /// <param name="team">The team.</param>
 /// <returns></returns>
 public List <PlayerNode> GetByTeam(PlayerTeam team)
 {
     return(Players.FindAll(x => x.Team == team));
 }
コード例 #42
0
 public void RemovePlayer(PlayerTeam Team)
 {
     s_teams.Remove(Team);
 }
コード例 #43
0
        public void RunAlgorithm()
        {
            PlayerTeam pt = new PlayerTeam();

            GetBestTeam(m_Deck, ref pt, StartIndex, ref m_Max.MAX, "BestForm");
        }
コード例 #44
0
 public void SetupMediatedData(Inventory inventory, PlayerTeam playerTeam)
 {
     this.inventory  = inventory;
     this.playerTeam = playerTeam;
 }
コード例 #45
0
        public void SetBlock(ushort x, ushort y, ushort z, BlockType blockType, PlayerTeam team)
        {
            if (x <= 0 || y <= 0 || z <= 0 || (int)x >= MAPSIZE - 1 || (int)y >= MAPSIZE - 1 || (int)z >= MAPSIZE - 1)
                return;

            if (blockType == BlockType.BeaconRed || blockType == BlockType.BeaconBlue)
            {
                Beacon newBeacon = new Beacon();
                newBeacon.ID = GenerateBeaconID();
                newBeacon.Team = blockType == BlockType.BeaconRed ? PlayerTeam.Red : PlayerTeam.Blue;
                beaconList[new Vector3(x, y, z)] = newBeacon;
                SendSetBeacon(new Vector3(x, y + 1, z), newBeacon.ID, newBeacon.Team);
            }

            if (blockType == BlockType.None && (blockList[x, y, z] == BlockType.BeaconRed || blockList[x, y, z] == BlockType.BeaconBlue))
            {
                if (beaconList.ContainsKey(new Vector3(x, y, z)))
                    beaconList.Remove(new Vector3(x, y, z));
                SendSetBeacon(new Vector3(x, y + 1, z), "", PlayerTeam.None);
            }

            blockList[x, y, z] = blockType;
            blockCreatorTeam[x, y, z] = team;

            // x, y, z, type, all bytes
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.BlockSet);
            msgBuffer.Write((byte)x);
            msgBuffer.Write((byte)y);
            msgBuffer.Write((byte)z);
            msgBuffer.Write((byte)blockType);
            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected)
                    netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableUnordered);

            if (blockType == BlockType.Lava)
                lavaBlockCount += 1;

            //ConsoleWrite("BLOCKSET: " + x + " " + y + " " + z + " " + blockType.ToString());
        }
コード例 #46
0
ファイル: WitchHut.cs プロジェクト: SuperPaw/Goblin-Game
 public void PayToHeal(int i, PlayerTeam team)
 {
     team.Members.ForEach(g => g.Heal());
     team.OnTreasureFound.Invoke(i);
 }
コード例 #47
0
 public string GetTeamName(PlayerTeam team)
 {
     switch (team)
     {
         case PlayerTeam.Red:
             return "RED";
         case PlayerTeam.Blue:
             return "BLUE";
     }
     return "";
 }
コード例 #48
0
ファイル: WitchHut.cs プロジェクト: SuperPaw/Goblin-Game
 public void Attack(PlayerTeam team)
 {
     WitchHutView.CloseHut();
     StartCoroutine(Spawning(team));
 }
コード例 #49
0
ファイル: GameEvent_CSGO.cs プロジェクト: twigglius/Aurora
 public static void SetTeam(PlayerTeam team)
 {
     current_team = team;
 }
コード例 #50
0
 public void SendSetBeacon(Vector3 position, string text, PlayerTeam team)
 {
     NetBuffer msgBuffer = netServer.CreateBuffer();
     msgBuffer.Write((byte)InfiniminerMessage.SetBeacon);
     msgBuffer.Write(position);
     msgBuffer.Write(text);
     msgBuffer.Write((byte)team);
     foreach (IClient player in playerList.Values)
         //if (netConn.Status == NetConnectionStatus.Connected)
         player.AddQueMsg(msgBuffer, NetChannel.ReliableInOrder2);
 }
コード例 #51
0
ファイル: WitchHut.cs プロジェクト: SuperPaw/Goblin-Game
    public void BuySkull(int amount, PlayerTeam team)
    {
        team.OnEquipmentFound.Invoke(EquipmentGen.GetEquipment(Equipment.EquipmentType.Skull), team.Leader);

        team.OnTreasureFound.Invoke(-amount);
    }
コード例 #52
0
        public bool Start()
        {
            //Setup the variable toggles
            varBindingsInitialize();

            int tmpMaxPlayers = 16;

            // Read in from the config file.
            DatafileWriter dataFile = new DatafileWriter("server.config.txt");
            if (dataFile.Data.ContainsKey("winningcash"))
                winningCashAmount = uint.Parse(dataFile.Data["winningcash"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("includelava"))
                includeLava = bool.Parse(dataFile.Data["includelava"]);
            if (dataFile.Data.ContainsKey("orefactor"))
                oreFactor = uint.Parse(dataFile.Data["orefactor"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("maxplayers"))
                tmpMaxPlayers = (int)Math.Min(32, uint.Parse(dataFile.Data["maxplayers"], System.Globalization.CultureInfo.InvariantCulture));
            if (dataFile.Data.ContainsKey("public"))
                varSet("public", bool.Parse(dataFile.Data["public"]), true);
            if (dataFile.Data.ContainsKey("servername"))
                varSet("name", dataFile.Data["servername"], true);
            if (dataFile.Data.ContainsKey("sandbox"))
                varSet("sandbox", bool.Parse(dataFile.Data["sandbox"]), true);
            if (dataFile.Data.ContainsKey("notnt"))
                varSet("tnt", !bool.Parse(dataFile.Data["notnt"]), true);
            if (dataFile.Data.ContainsKey("sphericaltnt"))
                varSet("stnt", bool.Parse(dataFile.Data["sphericaltnt"]), true);
            if (dataFile.Data.ContainsKey("insanelava"))
                varSet("insanelava", bool.Parse(dataFile.Data["insanelava"]), true);
            if (dataFile.Data.ContainsKey("shockspreadslava"))
                varSet("sspreads", bool.Parse(dataFile.Data["shockspreadslava"]), true);
            if (dataFile.Data.ContainsKey("roadabsorbs"))
                varSet("roadabsorbs", bool.Parse(dataFile.Data["roadabsorbs"]), true);
            if (dataFile.Data.ContainsKey("minelava"))
                varSet("minelava", bool.Parse(dataFile.Data["minelava"]), true);
            if (dataFile.Data.ContainsKey("levelname"))
                levelToLoad = dataFile.Data["levelname"];
            if (dataFile.Data.ContainsKey("greeter"))
                varSet("greeter", dataFile.Data["greeter"],true);

            bool autoannounce = true;
            if (dataFile.Data.ContainsKey("autoannounce"))
                autoannounce = bool.Parse(dataFile.Data["autoannounce"]);

            // Load the ban-list.
            banList = LoadBanList();

            // Load the admin-list
            admins = LoadAdminList();

            if (tmpMaxPlayers>=0)
                varSet("maxplayers", tmpMaxPlayers, true);

            // Initialize the server.
            NetConfiguration netConfig = new NetConfiguration("InfiniminerPlus");
            netConfig.MaxConnections = (int)varGetI("maxplayers");
            netConfig.Port = 5565;
            netServer = new InfiniminerNetServer(netConfig);
            netServer.SetMessageTypeEnabled(NetMessageType.ConnectionApproval, true);
            //netServer.SimulatedMinimumLatency = 0.1f;
            //netServer.SimulatedLatencyVariance = 0.05f;
            //netServer.SimulatedLoss = 0.1f;
            //netServer.SimulatedDuplicates = 0.05f;
            netServer.Start();

            // Store the last time that we did a flow calculation.
            DateTime lastFlowCalc = DateTime.Now;
            DateTime lastMapeaterCalc = DateTime.Now;

            //Check if we should autoload a level
            if (dataFile.Data.ContainsKey("autoload") && bool.Parse(dataFile.Data["autoload"]))
            {
                blockList = new BlockType[MAPSIZE, MAPSIZE, MAPSIZE];
                blockCreatorTeam = new PlayerTeam[MAPSIZE, MAPSIZE, MAPSIZE];
                LoadLevel(levelToLoad);
            }
            else
            {
                // Calculate initial lava flows.
                ConsoleWrite("CALCULATING INITIAL LAVA FLOWS");
                ConsoleWrite("TOTAL LAVA BLOCKS = " + newMap());
            }

            //Caculate the shape of spherical tnt explosions
            CalculateExplosionPattern();

            // Send the initial server list update.
            if (autoannounce)
                PublicServerListUpdate(true);

            lastMapBackup = DateTime.Now;
            ServerListener listener = new ServerListener(netServer,this);
            System.Threading.Thread listenerthread = new System.Threading.Thread(new ThreadStart(listener.start));
            listenerthread.Start();
            // Main server loop!
            ConsoleWrite("SERVER READY");
            Random randomizer = new Random(56235676);
            while (keepRunning)
            {

                // Process any messages that are here.

                //Time to backup map?
                TimeSpan mapUpdateTimeSpan = DateTime.Now - lastMapBackup;
                if (mapUpdateTimeSpan.TotalMinutes > 5)
                {
                    System.Threading.Thread backupthread = new System.Threading.Thread(new ThreadStart(BackupLevel));
                    backupthread.Start();
                    lastMapBackup = DateTime.Now;
                }

                // Time to send a new server update?
                PublicServerListUpdate(); //It checks for public server / time span

                //Time to terminate finished map sending threads?
                TerminateFinishedThreads();

                // Check for players who are in the zone to deposit.
                DepositForPlayers();

                // Is it time to do a lava calculation? If so, do it!

                if (varGetB("mapeater"))
                {
                    TimeSpan eaterSpan = DateTime.Now - lastMapeaterCalc;
                    if (eaterSpan.TotalMilliseconds > 500)
                    {
                        lastMapeaterCalc = DateTime.Now;
                        for (int i = 0; i < 200; i++)
                        {
                            ushort x = (ushort)randomizer.Next(0, 64);
                            ushort y = (ushort)randomizer.Next(0, 64);
                            for (ushort z = 62; z > 0; z--)
                            {
                                if (blockList[x, z, y] != BlockType.None)
                                {
                                    SetBlock(x, z, y, BlockType.None, PlayerTeam.None);
                                    break;
                                }
                            }

                        }
                    }

                }
                TimeSpan timeSpan = DateTime.Now - lastFlowCalc;
                if (timeSpan.TotalMilliseconds > 500)
                {
                    DoLavaStuff();
                    lastFlowCalc = DateTime.Now;
                }

                // Handle console keypresses.
                while (Console.KeyAvailable)
                {
                    ConsoleKeyInfo keyInfo = Console.ReadKey();
                    if (keyInfo.Key == ConsoleKey.Enter)
                        ConsoleProcessInput();
                    else if (keyInfo.Key == ConsoleKey.Backspace)
                    {
                        if (consoleInput.Length > 0)
                            consoleInput = consoleInput.Substring(0, consoleInput.Length - 1);
                        ConsoleRedraw();
                    }
                    else
                    {
                        consoleInput += keyInfo.KeyChar;
                        ConsoleRedraw();
                    }
                }

                // Is the game over?
                if (winningTeam != PlayerTeam.None && !restartTriggered)
                {
                    BroadcastGameOver();
                    restartTriggered = true;
                    restartTime = DateTime.Now.AddSeconds(10);
                }

                // Restart the server?
                if (restartTriggered && DateTime.Now > restartTime)
                {
                    SaveLevel("autosave_" + (UInt64)DateTime.Now.ToBinary() + ".lvl");
                    netServer.Shutdown("The server is restarting.");
                    return true;
                }

                // Pass control over to waiting threads.
                Thread.Sleep(1);
            }

            MessageAll("Server going down NOW!");

            netServer.Shutdown("The server was terminated.");
            return false;
        }
コード例 #53
0
 public void SetTeam(PlayerTeam team)
 {
     this.current_team = team;
 }
コード例 #54
0
    public void PickupObject(GameObject objToPick, Vector3 pickupPos)
    {
        if (gameObject.GetComponent <PlayerBase>().TeamType == PlayerTeam.PlayerTeamType.HideTeam)  //躲藏的玩家无法执行找操作
        {
            return;
        }
        else
        {
            if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu)
            {
                byte Gamestate = CServerItem.get().GetGameStatus();
                if (Gamestate != SocketDefines.GAME_STATUS_PLAY)
                {
                    return;
                }
            }
            else if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame)
            {
                if (GameManager.s_singleGameStatus != SocketDefines.GAME_STATUS_PLAY)
                {
                    return;
                }
            }
        }
        if (objToPick == null || this.Hp <= 0)
        {
            return;
        }

        if (this.IsAI)
        {
            //AI没有用射线检测,也就没有距离判断,所以这里要加入

            Vector3 distToPick = objToPick.transform.position - this.transform.position;
            if (distToPick.magnitude > ControlManager.s_MaxTouchCheckDistance)
            {
                Debug.LogError("-----------距离过远!!!!!" + distToPick.magnitude + " " + objToPick.transform.position + " " + this.transform.position);
                //if (objToPick.tag == "Hide" || objToPick.tag == "NormalFurniture") //objToPick.name
                {
                    UIManager.GetInstance().ShowPickupTooFarText();

                    return;
                }
            }
        }

        if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu)
        {
            // Pick event sync
            PlayerEventItem pickEvent = new PlayerEventItem();
            pickEvent.cbTeamType  = (byte)TeamType;
            pickEvent.wChairId    = (ushort)ChairID;
            pickEvent.cbAIId      = (byte)AIId;
            pickEvent.cbEventKind = (byte)PlayerBase.PlayerEventKind.Pick;
            GameObjectsManager.GetInstance().PlayerEventList.Add(pickEvent);
        }
        else
        {
            if (IsAI || !ControlManager.isPerson_1st)  //只有第三人称才有拾取动画
            {
                if (IsLocalHuman())
                {
                    EnableModelDisplay();
                }

                PlayPickupAnim();
                //if (_avatarAnimator != null)
                //{
                //    _avatarAnimator.SetBool("Pickup_b", true);
                //}
            }
        }

        PlayerBase pickedPlayer    = null;
        string     strObjToPickTag = null;

        if (this.IsAI)
        {
            //this是AI时,传的objToPick是根节点(PlayerBase都在根节点)

            pickedPlayer = objToPick.GetComponent <PlayerBase>();

            if (pickedPlayer == null)
            {
                //objToPick是场景中的物体,不是躲藏者

                strObjToPickTag = objToPick.tag;
            }
            else
            {
                Transform model = pickedPlayer.transform.FindChild("Model");
                if (model != null)
                {
                    strObjToPickTag = model.tag;    //tag在model节点
                }
                else
                {
                    Debug.LogError("PickupObject IsAI: model==null");
                }
            }
        }
        else
        {
            //this不是AI时,objToPick如果是躲藏者,传的是Model子节点,否则传的也是根节点

            pickedPlayer = objToPick.transform.parent.GetComponent <PlayerBase>();
            if (pickedPlayer == null)
            {
                //objToPick是场景中的物体,不是躲藏者

                strObjToPickTag = objToPick.tag;
            }
            else
            {
                strObjToPickTag = objToPick.tag;
            }
        }

        if (strObjToPickTag == "Hide" || (strObjToPickTag == "LocalHuman" && pickedPlayer != null && pickedPlayer.TeamType == PlayerTeam.PlayerTeamType.HideTeam)) //objToPick.name
        {
            ObjNamePicked = pickedPlayer.gameObject.name;
            Debug.Log(gameObject.name + " touched Hide: " + ObjNamePicked);

            if (IsLocalHuman())
            {
                Debug.Log("I'm touched Hide: " + ObjNamePicked);
            }

            // Check if objToPick is alive
            if (pickedPlayer != null)
            {
                if (pickedPlayer.IsDead())
                {
                    Debug.Log("It was already dead!");
                }
                else
                {
                    if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame)
                    {
                        if (IsAI && pickedPlayer.m_isStealth == 1) //AI警察不点隐身的躲藏者
                        {
                            return;
                        }
                        //击杀信息
                        if (gameObject.GetComponent <PlayerBase>().IsAI)
                        {
                            //String[] str = gameObject.name.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                            //String[] pickedStr = pickedPlayer.gameObject.name.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                            UIManager.GetInstance().ShowMiddleTips(gameObject.name + " 找到了: " + pickedPlayer.gameObject.name);
                        }
                        else
                        {
                            String[] str = GlobalUserInfo.getNickName().Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
                            //String[] pickedStr = pickedPlayer.gameObject.name.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                            UIManager.GetInstance().ShowMiddleTips(str[0] + " 找到了: " + pickedPlayer.gameObject.name);
                        }

                        // Heal self
                        AddHP();

                        if (m_hnGameManager != null && IsLocalHuman())  //本地玩家找到躲藏者提示
                        {
                            m_hnGameManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_HIDE_BEFOUNDED);
                        }

                        // make pickedPlayer dead and destroy later
                        pickedPlayer.MakeDead();
                        //if (!pickedPlayer.IsAI)
                        //{
                        //    PlayerChairIDOfPickedDead = pickedPlayer.ChairID;
                        //}
                    }
                    else
                    {
                        //Debug.LogWarning("+++++++++++++++++ " + pickedPlayer.m_isStealth + " " + IsAI);
                        if (pickedPlayer.m_isStealth == 1 && IsAI)  //AI警察不点隐身的躲藏者
                        {
                            //Debug.LogWarning("----------玩家隐身中");
                            return;
                        }
                        // Dead event sync
                        PlayerEventItem deadEvent = new PlayerEventItem();
                        deadEvent.cbTeamType  = (byte)pickedPlayer.TeamType;
                        deadEvent.wChairId    = (ushort)pickedPlayer.ChairID;
                        deadEvent.cbAIId      = pickedPlayer.AIId;
                        deadEvent.cbEventKind = (byte)PlayerEventKind.DeadByPicked;
                        //killer
                        deadEvent.nCustomData0 = (Int32)this.TeamType;
                        deadEvent.nCustomData1 = (Int32)this.ChairID;
                        deadEvent.nCustomData2 = (Int32)this.AIId;
                        GameObjectsManager.GetInstance().PlayerEventList.Add(deadEvent);
                    }

                    //警察找到躲藏者加分
                    GameScore += 50;
                }
            }
        }
        else if (strObjToPickTag == "NormalFurniture")
        {
            ObjNamePicked = objToPick.transform.parent.name;
            Debug.Log("touched normal furniture: " + ObjNamePicked);

            UIManager.GetInstance().ShowPickupWrongUI(pickupPos); //hit.point

            if (m_hnGameManager != null && IsLocalHuman())        //本地玩家点击错误物体提示
            {
                m_hnGameManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_EFFECT_PickObj);
            }
            if (IsLocalHuman())
            {
                UIManager.GetInstance().ShowMiddleTips("该物品不是玩家!");
            }
            if (UIManager.TimeLeft <= 45)   //剩余时间小于45秒时,警察无敌
            {
                return;
            }

            // Hurt self
            if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame)
            {
                DecHP();
            }
            else
            {
                PlayerEventItem decHpEvent = new PlayerEventItem();
                decHpEvent.cbTeamType  = (byte)this.TeamType;
                decHpEvent.wChairId    = (ushort)this.ChairID;
                decHpEvent.cbAIId      = (byte)this.AIId;
                decHpEvent.cbEventKind = (byte)PlayerBase.PlayerEventKind.DecHp;
                GameObjectsManager.GetInstance().PlayerEventList.Add(decHpEvent);
            }
        }
        else if (strObjToPickTag == "Tagger")
        {
            ObjNamePicked = pickedPlayer.gameObject.name;
            Debug.Log("touched Tagger: " + ObjNamePicked);
        }
        else
        {
            Debug.LogError("PickupObject: incorrect objToPickTag=" + strObjToPickTag);
        }


        //判断是否团灭
        int taggerCount = 0;
        int hideCount   = 0;

        for (PlayerTeam.PlayerTeamType teamType = PlayerTeam.PlayerTeamType.TaggerTeam; teamType < PlayerTeam.PlayerTeamType.MaxTeamNum; teamType++)
        {
            PlayerTeam team = GameObjectsManager.GetInstance().GetPlayerTeam(teamType);
            if (team == null)
            {
                continue;
            }
            for (int i = 0; i < team.GetPlayerNum(); i++)
            {
                PlayerBase playerBase = GameObjectsManager.GetInstance().GetPlayer(teamType, i);
                if (playerBase != null && playerBase.Hp != 0)
                {
                    if (teamType == PlayerTeam.PlayerTeamType.TaggerTeam)
                    {
                        taggerCount++;
                    }
                    else if (teamType == PlayerTeam.PlayerTeamType.HideTeam)
                    {
                        hideCount++;
                    }
                }
            }
        }
        if (taggerCount == 0 || hideCount == 0)
        {
            if (GameManager.s_gameSingleMultiType == GameSingleMultiType.SingleGame)
            {
                if (UIManager.GetInstance() != null)
                {
                    UIManager.GetInstance().ShowWinOrLose();
                }
                m_hnGameManager.StopSingleGame();
                m_hnGameManager.PlayAgainSingleGame();
            }
        }
    }
コード例 #55
0
 public List <PlayerNode> GetTeam(PlayerTeam Team)
 {
     return(_Players.FindAll(x => x.Team == Team));
 }
コード例 #56
0
        public void ArtifactTeamBonus(PlayerTeam team, int cc, bool state)
        {
            NetBuffer msgBuffer;
            string artmessage = "";

            if (state)
            {
                artifactActive[(byte)team, cc]++;
                msgBuffer = netServer.CreateBuffer();
                msgBuffer.Write((byte)InfiniminerMessage.ChatMessage);
                if (team == PlayerTeam.Red)
                    msgBuffer.Write((byte)ChatMessageType.SayRedTeam);
                else if (team == PlayerTeam.Blue)
                    msgBuffer.Write((byte)ChatMessageType.SayBlueTeam);

                artmessage = "We now possess the " + ArtifactInformation.GetName(cc);
            }
            else
            {
                artifactActive[(byte)team, cc]--;
                msgBuffer = netServer.CreateBuffer();
                msgBuffer.Write((byte)InfiniminerMessage.ChatMessage);
                if (team == PlayerTeam.Red)
                    msgBuffer.Write((byte)ChatMessageType.SayRedTeam);
                else if (team == PlayerTeam.Blue)
                    msgBuffer.Write((byte)ChatMessageType.SayBlueTeam);

                artmessage = "The " + ArtifactInformation.GetName(cc) + " has been lost";
            }

            switch(cc)
            {
                case 1://material artifact
                    if (state)
                    {
                        artmessage += ", regenerating team ore periodically";
                    }
                    else
                    {
                        artmessage += " reducing our periodic ore supply";
                    }
                    break;
                case 2://vampire artifact
                    if (state)
                    {
                        artmessage += ", giving our team minor life stealing attacks";
                    }
                    else
                    {
                        artmessage += " reducing our life stealing attacks";
                    }
                    break;
                case 3://regeneration artifact
                    if (state)
                    {
                        teamRegeneration[(byte)team] += 2;
                        artmessage += ", regenerating faster";
                    }
                    else
                    {
                        teamRegeneration[(byte)team] -= 2;
                        artmessage += " regenerating slower";
                    }
                    break;

                case 4://aqua
                    if (artifactActive[(byte)team, cc] < 1)
                    {
                        artmessage += " and we may no longer water breathe or dig underwater";
                        SendActiveArtifactUpdate(team, cc);
                    }
                    else if (artifactActive[(byte)team, cc] == 1)
                    {
                        artmessage += ", we may now breathe and dig underwater";
                        SendActiveArtifactUpdate(team, cc);
                    }
                    break;
                case 5://golden artifact
                    if (state)
                    {
                        artmessage += ", generating periodic gold deposits for our team";
                    }
                    else
                    {
                        artmessage += " reducing our periodic gold supplies";
                    }
                    break;
                case 6://storm artifact
                    if (state)
                    {
                        artmessage += ", granting immunity to any area effects caused by artifacts";
                    }
                    else
                    {
                        if(artifactActive[(byte)team, 6] == 0)
                        artmessage += " making us vulnerable to area effects caused by artifacts";
                    }
                    break;
                case 7://reflect artifact
                    if (state)
                    {
                        artmessage += ", causing our team blocks to reflect a small amount of damage";
                    }
                    else
                    {
                        if (artifactActive[(byte)team, 7] == 0)
                            artmessage += " removing our block damage reflection";
                    }
                    break;
                case 8://medical artifact
                    if (state)
                    {
                        artmessage += ", healing our teams ailments";
                    }
                    else
                    {
                        if (artifactActive[(byte)team, 8] == 0)
                            artmessage += " leaving us without ailment protection";
                    }
                    break;
                case 9://stone artifact
                    if (state)
                    {
                        artmessage += ", reducing any knockbacks";
                        SendActiveArtifactUpdate(team, cc);
                    }
                    else
                    {
                        if (artifactActive[(byte)team, cc] == 0)
                            artmessage += " leaving us without knockback protection";

                        SendActiveArtifactUpdate(team, cc);
                    }
                    break;
            }

            if (artmessage != "")
            {
                artmessage += "!";
                msgBuffer.Write(Defines.Sanitize(artmessage));
                foreach (NetConnection netConn in playerList.Keys)
                    if (netConn.Status == NetConnectionStatus.Connected && playerList[netConn].Team == team)
                        netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableInOrder2);
            }
        }
コード例 #57
0
        public void UpdateNetwork(GameTime gameTime)
        {
            // Update the server with our status.
            timeSinceLastUpdate += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceLastUpdate > 0.05)
            {
                timeSinceLastUpdate = 0;
                if (CurrentStateType == "Infiniminer.States.MainGameState")
                {
                    propertyBag.SendPlayerUpdate();
                }
            }

            // Recieve messages from the server.
            while ((msgBuffer = propertyBag.netClient.ReadMessage()) != null)
            {
                switch (msgBuffer.MessageType)
                {
                case NetIncomingMessageType.StatusChanged:
                {
                    if (propertyBag.netClient.ConnectionStatus == NetConnectionStatus.RespondedConnect)
                    {
                        anyPacketsReceived = true;
                    }
                    if (propertyBag.netClient.ConnectionStatus == NetConnectionStatus.Disconnected)
                    {
                        anyPacketsReceived = false;
                        try
                        {
                            string[] reason = msgBuffer.ReadString().Split(";".ToCharArray());
                            if (reason.Length < 2 || reason[0] == "VER")
                            {
                                InfiniminerMessageBox.Show("Error: client/server version incompability!\r\nServer: " + msgBuffer.ReadString() + "\r\nClient: " + Defines.INFINIMINER_VERSION);
                            }
                            else
                            {
                                InfiniminerMessageBox.Show("Error: you are banned from this server!");
                            }
                        }
                        catch { }
                        ChangeState("Infiniminer.States.ServerBrowserState");
                    }
                }
                break;

                case NetIncomingMessageType.Data:
                {
                    try
                    {
                        InfiniminerMessage dataType = (InfiniminerMessage)msgBuffer.ReadByte();
                        switch (dataType)
                        {
                        case InfiniminerMessage.BlockBulkTransfer:
                        {
                            anyPacketsReceived = true;

                            try
                            {
                                //This is either the compression flag or the x coordiante
                                byte isCompressed = msgBuffer.ReadByte();
                                byte x;
                                byte y;

                                //255 was used because it exceeds the map size - of course, bytes won't work anyway if map sizes are allowed to be this big, so this method is a non-issue
                                if (isCompressed == 255)
                                {
                                    var compressed       = msgBuffer.ReadBytes(msgBuffer.LengthBytes - (int)(msgBuffer.Position / 8));
                                    var compressedstream = new System.IO.MemoryStream(compressed);
                                    var decompresser     = new System.IO.Compression.GZipStream(compressedstream, System.IO.Compression.CompressionMode.Decompress);

                                    x = (byte)decompresser.ReadByte();
                                    y = (byte)decompresser.ReadByte();
                                    propertyBag.mapLoadProgress[x, y] = true;
                                    for (byte dy = 0; dy < 16; dy++)
                                    {
                                        for (byte z = 0; z < 64; z++)
                                        {
                                            BlockType blockType = (BlockType)decompresser.ReadByte();
                                            if (blockType != BlockType.None)
                                            {
                                                propertyBag.blockEngine.downloadList[x, y + dy, z] = blockType;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    x = isCompressed;
                                    y = msgBuffer.ReadByte();
                                    propertyBag.mapLoadProgress[x, y] = true;
                                    for (byte dy = 0; dy < 16; dy++)
                                    {
                                        for (byte z = 0; z < 64; z++)
                                        {
                                            BlockType blockType = (BlockType)msgBuffer.ReadByte();
                                            if (blockType != BlockType.None)
                                            {
                                                propertyBag.blockEngine.downloadList[x, y + dy, z] = blockType;
                                            }
                                        }
                                    }
                                }
                                bool downloadComplete = true;
                                for (x = 0; x < 64; x++)
                                {
                                    for (y = 0; y < 64; y += 16)
                                    {
                                        if (propertyBag.mapLoadProgress[x, y] == false)
                                        {
                                            downloadComplete = false;
                                            break;
                                        }
                                    }
                                }
                                if (downloadComplete)
                                {
                                    ChangeState("Infiniminer.States.TeamSelectionState");
                                    if (!NoSound)
                                    {
                                        MediaPlayer.Stop();
                                    }
                                    propertyBag.blockEngine.DownloadComplete();
                                }
                            }
                            catch (Exception e)
                            {
                                Console.OpenStandardError();
                                Console.Error.WriteLine(e.Message);
                                Console.Error.WriteLine(e.StackTrace);
                                Console.Error.Close();
                            }
                        }
                        break;

                        case InfiniminerMessage.SetBeacon:
                        {
                            Vector3    position = msgBuffer.ReadVector3();
                            string     text     = msgBuffer.ReadString();
                            PlayerTeam team     = (PlayerTeam)msgBuffer.ReadByte();

                            if (text == "")
                            {
                                if (propertyBag.beaconList.ContainsKey(position))
                                {
                                    propertyBag.beaconList.Remove(position);
                                }
                            }
                            else
                            {
                                Beacon newBeacon = new Beacon();
                                newBeacon.ID   = text;
                                newBeacon.Team = team;
                                propertyBag.beaconList.Add(position, newBeacon);
                            }
                        }
                        break;

                        case InfiniminerMessage.TriggerConstructionGunAnimation:
                        {
                            propertyBag.constructionGunAnimation = msgBuffer.ReadFloat();
                            if (propertyBag.constructionGunAnimation <= -0.1)
                            {
                                propertyBag.PlaySound(InfiniminerSound.RadarSwitch);
                            }
                        }
                        break;

                        case InfiniminerMessage.ResourceUpdate:
                        {
                            // ore, cash, weight, max ore, max weight, team ore, red cash, blue cash, all uint
                            propertyBag.playerOre       = msgBuffer.ReadUInt32();
                            propertyBag.playerCash      = msgBuffer.ReadUInt32();
                            propertyBag.playerWeight    = msgBuffer.ReadUInt32();
                            propertyBag.playerOreMax    = msgBuffer.ReadUInt32();
                            propertyBag.playerWeightMax = msgBuffer.ReadUInt32();
                            propertyBag.teamOre         = msgBuffer.ReadUInt32();
                            propertyBag.teamRedCash     = msgBuffer.ReadUInt32();
                            propertyBag.teamBlueCash    = msgBuffer.ReadUInt32();
                        }
                        break;

                        case InfiniminerMessage.BlockSet:
                        {
                            // x, y, z, type, all bytes
                            byte      x         = msgBuffer.ReadByte();
                            byte      y         = msgBuffer.ReadByte();
                            byte      z         = msgBuffer.ReadByte();
                            BlockType blockType = (BlockType)msgBuffer.ReadByte();
                            if (blockType == BlockType.None)
                            {
                                if (propertyBag.blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                                {
                                    propertyBag.blockEngine.RemoveBlock(x, y, z);
                                }
                            }
                            else
                            {
                                if (propertyBag.blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
                                {
                                    propertyBag.blockEngine.RemoveBlock(x, y, z);
                                }
                                propertyBag.blockEngine.AddBlock(x, y, z, blockType);
                                CheckForStandingInLava();
                            }
                        }
                        break;

                        case InfiniminerMessage.TriggerExplosion:
                        {
                            Vector3 blockPos = msgBuffer.ReadVector3();

                            // Play the explosion sound.
                            propertyBag.PlaySound(InfiniminerSound.Explosion, blockPos);

                            // Create some particles.
                            propertyBag.particleEngine.CreateExplosionDebris(blockPos);

                            // Figure out what the effect is.
                            float distFromExplosive = (blockPos + 0.5f * Vector3.One - propertyBag.playerPosition).Length();
                            if (distFromExplosive < 3)
                            {
                                propertyBag.KillPlayer(Defines.deathByExpl);                //"WAS KILLED IN AN EXPLOSION!");
                            }
                            else if (distFromExplosive < 8)
                            {
                                // If we're not in explosion mode, turn it on with the minimum ammount of shakiness.
                                if (propertyBag.screenEffect != ScreenEffect.Explosion)
                                {
                                    propertyBag.screenEffect        = ScreenEffect.Explosion;
                                    propertyBag.screenEffectCounter = 2;
                                }
                                // If this bomb would result in a bigger shake, use its value.
                                propertyBag.screenEffectCounter = Math.Min(propertyBag.screenEffectCounter, (distFromExplosive - 2) / 5);
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerSetTeam:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Team = (PlayerTeam)msgBuffer.ReadByte();
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerJoined:
                        {
                            uint   playerId    = msgBuffer.ReadUInt32();
                            string playerName  = msgBuffer.ReadString();
                            bool   thisIsMe    = msgBuffer.ReadBoolean();
                            bool   playerAlive = msgBuffer.ReadBoolean();
                            propertyBag.playerList[playerId]            = new Player(null, (Game)this);
                            propertyBag.playerList[playerId].Handle     = playerName;
                            propertyBag.playerList[playerId].ID         = playerId;
                            propertyBag.playerList[playerId].Alive      = playerAlive;
                            propertyBag.playerList[playerId].AltColours = customColours;
                            propertyBag.playerList[playerId].redTeam    = red;
                            propertyBag.playerList[playerId].blueTeam   = blue;
                            if (thisIsMe)
                            {
                                propertyBag.playerMyId = playerId;
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerLeft:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                propertyBag.playerList.Remove(playerId);
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerDead:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Alive = false;
                                propertyBag.particleEngine.CreateBloodSplatter(player.Position, player.Team == PlayerTeam.Red ? Color.Red : Color.Blue);
                                if (playerId != propertyBag.playerMyId)
                                {
                                    propertyBag.PlaySound(InfiniminerSound.Death, player.Position);
                                }
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerAlive:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.Alive = true;
                            }
                        }
                        break;

                        case InfiniminerMessage.PlayerUpdate:
                        {
                            uint playerId = msgBuffer.ReadUInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                Player player = propertyBag.playerList[playerId];
                                player.UpdatePosition(msgBuffer.ReadVector3(), gameTime.TotalGameTime.TotalSeconds);
                                player.Heading   = msgBuffer.ReadVector3();
                                player.Tool      = (PlayerTools)msgBuffer.ReadByte();
                                player.UsingTool = msgBuffer.ReadBoolean();
                                player.Score     = (uint)(msgBuffer.ReadUInt16() * 100);
                            }
                        }
                        break;

                        case InfiniminerMessage.GameOver:
                        {
                            propertyBag.teamWinners = (PlayerTeam)msgBuffer.ReadByte();
                        }
                        break;

                        case InfiniminerMessage.ChatMessage:
                        {
                            ChatMessageType chatType   = (ChatMessageType)msgBuffer.ReadByte();
                            string          chatString = Defines.Sanitize(msgBuffer.ReadString());
                            //Time to break it up into multiple lines
                            propertyBag.addChatMessage(chatString, chatType, 10);
                        }
                        break;

                        case InfiniminerMessage.PlayerPing:
                        {
                            uint playerId = (uint)msgBuffer.ReadInt32();
                            if (propertyBag.playerList.ContainsKey(playerId))
                            {
                                if (propertyBag.playerList[playerId].Team == propertyBag.playerTeam)
                                {
                                    propertyBag.playerList[playerId].Ping = 1;
                                    propertyBag.PlaySound(InfiniminerSound.Ping);
                                }
                            }
                        }
                        break;

                        case InfiniminerMessage.PlaySound:
                        {
                            InfiniminerSound sound       = (InfiniminerSound)msgBuffer.ReadByte();
                            bool             hasPosition = msgBuffer.ReadBoolean();
                            if (hasPosition)
                            {
                                Vector3 soundPosition = msgBuffer.ReadVector3();
                                propertyBag.PlaySound(sound, soundPosition);
                            }
                            else
                            {
                                propertyBag.PlaySound(sound);
                            }
                        }
                        break;
                        }
                    }
                    catch { }         //Error in a received message
                }
                break;
                }
            }

            // Make sure our network thread actually gets to run.
            Thread.Sleep(1);
        }
コード例 #58
0
        public void ExplosionEffectAtPoint(float x, float y, float z, int strength, PlayerTeam team)
        {
            //SetBlock((ushort)x, (ushort)y, (ushort)z, BlockType.Fire, PlayerTeam.None);//might be better at detonate
            //blockListContent[x, y, z, 0] = 6;//fire gets stuck?
            double dist = 0.0f;
            uint damage = 0;

            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected && playerList[netConn].Alive)
                {
                    if(playerList[netConn].Alive)//needs teamcheck
                    if (playerList[netConn].Team != team)
                    {
                        dist = Distf(playerList[netConn].Position, new Vector3(x, y, z));
                        if (dist <= strength)//player in range of bomb on server?
                        {
                            damage = (uint)((strength*10) - (dist*10));//10 dmg per dist
                            if (playerList[netConn].Health > damage)
                            {
                                playerList[netConn].Health -= damage;
                                SendHealthUpdate(playerList[netConn]);

                                NetBuffer msgBufferB = netServer.CreateBuffer();
                                msgBufferB.Write((byte)InfiniminerMessage.PlayerSlap);
                                msgBufferB.Write(playerList[netConn].ID);//getting slapped
                                msgBufferB.Write((uint)0);//attacker
                                SendHealthUpdate(playerList[netConn]);

                                foreach (NetConnection netConnB in playerList.Keys)
                                    if (netConnB.Status == NetConnectionStatus.Connected)
                                        netServer.SendMessage(msgBufferB, netConnB, NetChannel.ReliableUnordered);
                            }
                            else
                            {
                                Player_Dead(playerList[netConn],"EXPLODED!");
                            }
                        }
                    }
                }

            // Send off the explosion to clients.
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.TriggerExplosion);
            msgBuffer.Write(new Vector3(x, y, z));
            msgBuffer.Write(strength);
            foreach (NetConnection netConn in playerList.Keys)
                if (netConn.Status == NetConnectionStatus.Connected)
                    netServer.SendMessage(msgBuffer, netConn, NetChannel.ReliableUnordered);
        }
コード例 #59
0
	void OnOwnerChanged(PlayerTeam newOwner)
	{
		owner = newOwner;
		indicatorMat.color = owner == PlayerTeam.TeamYellow ? teamColors[0] : teamColors[1];
	}
コード例 #60
0
 public bool HingeBlockTypes(BlockType block, PlayerTeam team)
 {
     switch (block)
     {
         case BlockType.SolidRed:
         case BlockType.SolidRed2:
             if (team == PlayerTeam.Red)
                 return true;
             break;
         case BlockType.SolidBlue2:
         case BlockType.SolidBlue:
             if (team == PlayerTeam.Blue)
             return true;
             break;
         default:
             break;
     }
     return false;
 }