示例#1
0
 public void Play()
 {
     Debug.Log("PLAY");
     selections.ForEach(selection =>
     {
         Debug.Log($"SELECTED {selection.index}");
         Faction faction = factions[selection.index];
         if (faction != null)
         {
             var playerId = selection.playerId;
             PersistentData.Player player = new PersistentData.Player()
             {
                 playerId = playerId,
                 fighters = new List <Fighter>(),
                 name     = $"PLAYER {playerId}"
             };
             foreach (var p in faction.prefabs)
             {
                 Debug.Log($"name: {p.name}");
                 Debug.Log($"uidata: {p.GetComponent<UiData>()}");
                 player.fighters.Add(new Fighter()
                 {
                     life     = 100,
                     alive    = true,
                     name     = p.GetComponent <UiData>().title,
                     playerId = playerId,
                     prefab   = p
                 });
             }
             PersistentData.Players.Add(player);
         }
     });
     PersistentData.playerCount = PlayerCount;
     PersistentData.Players.ForEach(p =>
     {
         Debug.Log($"NAME {p.name}/{p.playerId}");
         p.fighters.ForEach(f => Debug.Log($"fighter {f.name} {f.alive} {f.life} {f.prefab}"));
     });
     SceneManager.LoadScene("FighterSelectorJoystick");
 }
示例#2
0
 public void Play()
 {
     Debug.Log("PLAY");
     foreach (var fs in factionSelects)
     {
         Debug.Log($"SELECTED {fs.SelectedFaction}");
         if (fs.SelectedFaction != null)
         {
             var playerId = fs.PlayerId;
             PersistentData.Player player = new PersistentData.Player()
             {
                 playerId = playerId,
                 fighters = new List <Fighter>(),
                 name     = $"PLAYER {playerId}"
             };
             foreach (var p in fs.SelectedFaction.prefabs)
             {
                 Debug.Log($"name: {p.name}");
                 Debug.Log($"uidata: {p.GetComponent<UiData>()}");
                 player.fighters.Add(new Fighter()
                 {
                     life     = 100,
                     alive    = true,
                     name     = p.GetComponent <UiData>().title,
                     playerId = playerId,
                     prefab   = p
                 });
             }
             PersistentData.Players.Add(player);
         }
     }
     PersistentData.Players.ForEach(p =>
     {
         Debug.Log($"NAME {p.name}/{p.playerId}");
         p.fighters.ForEach(f => Debug.Log($"fighter {f.name} {f.alive} {f.life} {f.prefab}"));
     });
     SceneManager.LoadScene("FactionFighterSelector");
 }
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try {
                if (_senderInfo.RemoteClientInfo != null)
                {
                    if (_params.Count >= 1 && _params [0].ToLower().Equals("nearby"))
                    {
                        _params.Add(_senderInfo.RemoteClientInfo.playerId);
                    }
                }

                World w = GameManager.Instance.World;
                PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList();

                bool     summaryOnly       = false;
                string   steamIdFilter     = string.Empty;
                Vector3i closeTo           = default(Vector3i);
                bool     onlyCloseToPlayer = false;
                int      closeToDistance   = 32;

                if (_params.Count == 1)
                {
                    long tempLong;

                    if (_params [0].ToLower().Equals("summary"))
                    {
                        summaryOnly = true;
                    }
                    else if (_params [0].Length == 17 && long.TryParse(_params [0], out tempLong))
                    {
                        steamIdFilter = _params [0];
                    }
                    else
                    {
                        ClientInfo ci = ConsoleHelper.ParseParamIdOrName(_params [0]);
                        if (ci != null)
                        {
                            steamIdFilter = ci.playerId;
                        }
                        else
                        {
                            SdtdConsole.Instance.Output("Player name or entity id \"" + _params [0] + "\" not found.");
                            return;
                        }
                    }
                }
                else if (_params.Count >= 2)
                {
                    if (_params [0].ToLower().Equals("nearby"))
                    {
                        try {
                            if (_params.Count == 3)
                            {
                                if (!int.TryParse(_params[1], out closeToDistance))
                                {
                                    SdtdConsole.Instance.Output("Given radius is not an integer!");
                                }
                            }
                            ClientInfo   ci = ConsoleHelper.ParseParamSteamIdOnline(_params [_params.Count - 1]);
                            EntityPlayer ep = w.Players.dict [ci.entityId];
                            closeTo           = new Vector3i(ep.GetPosition());
                            onlyCloseToPlayer = true;
                        } catch (Exception e) {
                            SdtdConsole.Instance.Output("Error getting current player's position");
                            Log.Out("Error in ListLandProtection.Run: " + e);
                        }
                    }
                    else
                    {
                        SdtdConsole.Instance.Output("Illegal parameter list");
                        return;
                    }
                }
                Boolean Bol = false;
                Dictionary <Vector3i, PersistentPlayerData> d = ppl.m_lpBlockMap;
                if (d != null)
                {
                    Dictionary <PersistentPlayerData, List <Vector3i> > owners = new Dictionary <PersistentPlayerData, List <Vector3i> > ();
                    foreach (KeyValuePair <Vector3i, PersistentPlayerData> kvp in d)
                    {
                        if (!onlyCloseToPlayer || (Math.Abs(kvp.Key.x - closeTo.x) <= closeToDistance && Math.Abs(kvp.Key.z - closeTo.z) <= closeToDistance))
                        {
                            if (!owners.ContainsKey(kvp.Value))
                            {
                                owners.Add(kvp.Value, new List <Vector3i> ());
                            }
                            owners [kvp.Value].Add(kvp.Key);
                        }
                    }

                    foreach (KeyValuePair <PersistentPlayerData, List <Vector3i> > kvp in owners)
                    {
                        if (steamIdFilter.Length == 0 || kvp.Key.PlayerId.Equals(steamIdFilter))
                        {
                            PersistentData.Player p = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId, false];
                            string name             = string.Empty;
                            if (p != null)
                            {
                                name = p.Name;
                            }
                            name += " (" + kvp.Key.PlayerId + ")";
                            Bol   = true;

                            SdtdConsole.Instance.Output(String.Format(
                                                            "Player \"{0}\" owns {3} keystones (protected: {1}, current hardness multiplier: {2})",
                                                            name,
                                                            w.IsLandProtectionValidForPlayer(kvp.Key),
                                                            w.GetLandProtectionHardnessModifierForPlayer(kvp.Key),
                                                            kvp.Value.Count)
                                                        );
                            if (!summaryOnly)
                            {
                                foreach (Vector3i v in kvp.Value)
                                {
                                    SdtdConsole.Instance.Output("   (" + v.ToString() + ")");
                                }
                            }
                        }
                    }
                }
                if (Bol == false)
                {
                    SdtdConsole.Instance.Output("Player not found...");
                }

                if (steamIdFilter.Length == 0)
                {
                    SdtdConsole.Instance.Output("Total of " + d.Count + " keystones in the game");
                }
            } catch (Exception e) {
                Log.Out("Error in ListLandProtection.Run: " + e);
            }
        }
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try {
                World w   = GameManager.Instance.World;
                int   num = 0;
                foreach (KeyValuePair <int, EntityPlayer> current in w.Players.dict)
                {
                    ClientInfo clientInfoFromEntityID = ConnectionManager.Instance.GetClientInfoForEntityId(current.Key);
                    //CommonMappingFunctions.GetClientInfoFromEntityID (current.Key);
                    string ip = string.Empty;
                    //int str1 = 0;
                    int    str2 = 0;
                    string str3 = "unk";
                    string str4 = "unk";
                    if (clientInfoFromEntityID != null)
                    {
                        ip = clientInfoFromEntityID.ip;
                        //str1 = clientInfoFromEntityID.netConnection.clientId;
                        str2 = clientInfoFromEntityID.entityId;
                        str3 = clientInfoFromEntityID.ownerId;
                        str4 = clientInfoFromEntityID.playerId;
                    }
                    PersistentData.Player p = PersistentData.PersistentContainer.Instance.Players ["" + current.Value.entityId, false];
                    SdtdConsole.Instance.Output(string.Concat(new object[]
                    {
                        string.Empty,
                        ++num,
                        ". id=",
                        current.Value.entityId,
                        ", ",
                        current.Value.EntityName,
                        ", pos=",
                        current.Value.GetPosition(),
                        ", Hp=",
                        current.Value.Health,
                        ", dth=",
                        current.Value.Died,
                        ", zkill=",
                        current.Value.KilledZombies,
                        ", pkill=",
                        current.Value.KilledPlayers,
                        ", scr=",
                        current.Value.Score,
                        ", Sid=",
                        str4,
                        ", ip=",
                        ip,
                        ", ping=",
                        current.Value.pingToServer,
                        ", level=",
                        current.Value.GetLevel(),
                        ", playtime=",
                        p.TotalPlayTime / 60


                        /*,
                         * " clid=",
                         * str1,
                         * ". entid=",
                         * str2,
                         * ", ownid",
                         * str3,
                         * ", plyid",
                         * str4*/
                    }));
                }
                SdtdConsole.Instance.Output("Total of " + w.Players.list.Count + " in the KFP game");
            } catch (Exception e) {
                Log.Out("Error in ListPlayersExtended.Run: " + e);
            }
        }