/// <summary> /// Initialize the ServerNetworkManager instance. /// </summary> /// <param name="WorldManager">Supplies the game world manager to which /// the network manager instance is bound.</param> /// <param name="LocalServerId">Supplies the server id of the local /// server.</param> /// <param name="Script">Supplies the main script object.</param> public ServerNetworkManager(GameWorldManager WorldManager, int LocalServerId, ACR_ServerCommunicator Script) { SocketIo.Initialize(Script); this.WorldManager = WorldManager; this.LocalServerId = LocalServerId; }
protected override void OnUpdate() { //List<PathfindingJobGrid> jobs = new List<PathfindingJobGrid>(); NativeList <JobHandle> handles = new NativeList <JobHandle>(Allocator.Temp); Grid <GridPathNode> grid = GameWorldManager.Instance().grid; NativeArray <GridPathNode> nodes = GetArrayFromGrid(grid); int2 gridSize = new int2(grid.Width, grid.Height); //double startA = UnityEngine.Time.realtimeSinceStartup; Entities.ForEach((Entity e, ref GridPathRequest pathRequest) => { NativeArray <GridPathNode> tmpNodes = new NativeArray <GridPathNode>(nodes, Allocator.TempJob); handles.Add(new PathfindingJobGrid { gridSize = gridSize, nodes = tmpNodes, start = pathRequest.start, end = pathRequest.end }.Schedule()); //jobs.Add(job); //job.Schedule()); PostUpdateCommands.RemoveComponent <PathRequest>(e); }); //double endA = UnityEngine.Time.realtimeSinceStartup; //Debug.Log("A: " + (endA - startA)); JobHandle.CompleteAll(handles); //jobs.Clear(); nodes.Dispose(); handles.Dispose(); }
public GameCharacter(GameWorldManager WorldManager) { this.WorldManager = WorldManager; Player = null; Server = null; Visited = false; }
public static GameWorldManager Instance() { if (gwm == null) { gwm = new GameWorldManager(); } return(gwm); }
/// <summary> /// Construct a new GameServer object. /// </summary> /// <param name="WorldManager">Supplies the game world manager. /// </param> public GameServer(GameWorldManager WorldManager) { this.WorldManager = WorldManager; this.Characters = new List <GameCharacter>(); this.ServerIPAddress = IPAddress.None; this.DatabaseOnline = true; this.Public = false; }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { if(anObjectIn.GetBool("Gathered")) { ourGWM.destroyObject(ourGWM.getResourceDictionary()[anObjectIn.GetInt("ID")]); ourGWM.getResourceDictionary().Remove(anObjectIn.GetInt("ID")); } }
// Use this for initialization void Start() { ourGWM = GameObject.Find("SceneScriptsObject").GetComponent <GameWorldManager>(); jumpKey = KeyCode.W; crouchKey = KeyCode.S; forwardKey = KeyCode.D; backwardKey = KeyCode.A; }
// Use this for initialization void Start() { ourGameUI = GameObject.Find("SceneScriptsObject").GetComponent<GameUI>(); ourGWM = GameObject.Find("SceneScriptsObject").GetComponent<GameWorldManager>(); ourPlayerActionDictionary.Add("Resource", new GatherResourceAction()); ourPlayerActionDictionary.Add("Center Node", new CenterNodeAction()); ourPlayerActionDictionary.Add("Use Item", new UseItemAction()); ourPlayerActionDictionary.Add("ContributeCenterNode", new ContributeCenterNodeAction()); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aSettlementName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("LocationArray"); int level = anObjectIn.GetInt("CenterNodeLevel"); GameObject aSettlement = ourGWM.createObject("Prefabs/Settlements/" + aSettlementName + "/" + level.ToString()); aSettlement.name = "Settlement_" + aSettlementName + "_" + ID; aSettlement.transform.position = new Vector3(location[0], location[1], location[2]); }
private void CreateSingleton() { if (Instance == null) { Instance = this; //DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aResourceName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("Location"); GameObject aResource = ourGWM.createObject("Prefabs/Resources/" + aResourceName); aResource.name = "Resource_" + aResourceName + "_" + ID; aResource.transform.position = new Vector3(location[0], location[1], location[2]); //Add Newly spawned resource to Dictionary ourGWM.getResourceDictionary().Add(ID, aResource); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { ourGWM.destroyObject("GameCharacter_" + aCharacterName); ourGWM.getPlayerDictionary().Remove(aCharacterName); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float Rotation = anObjectIn.GetFloat("Rotation"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetRotation(Rotation); } }
/// <summary> /// Retrieve the properties of the player from the database. /// </summary> /// <param name="Database">Supplies the database connection to use for /// queries, if required. The active rowset may be consumed.</param> public void PopulateFromDatabase(IALFADatabase Database) { Database.ACR_SQLQuery(String.Format( "SELECT `Name`, `IsDM` FROM `players` WHERE `ID` = {0}", PlayerId)); if (!Database.ACR_SQLFetch()) { throw new ApplicationException("Failed to populate data for player " + PlayerId); } PlayerName = Database.ACR_SQLGetData(0); IsDM = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(1)); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float[] LocationArray = anObjectIn.GetFloatArray("Location"); bool IsMoving = anObjectIn.GetBool("IsMoving"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetPlayerMoving(IsMoving); ourGWM.getPlayerDictionary()[aCharacterName].transform.position = new Vector3(LocationArray[0], LocationArray[1], LocationArray[2]); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aNPCName = anObjectIn.GetUtfString("Name"); int ID = anObjectIn.GetInt("ID"); float[] location = anObjectIn.GetFloatArray("Location"); GameObject aNPC = ourGWM.createObject("Prefabs/NPC/" + aNPCName); aNPC.name = "NPC_" + aNPCName + "_" + ID; aNPC.AddComponent<RemotePlayerController>(); aNPC.transform.position = new Vector3(location[0], location[1], location[2]); aNPC.GetComponentInChildren<TextMesh>().text = aNPCName; //Add Newly spawned player to Dictionary ourGWM.getNPCDictionary().Add(ID, aNPC); }
/// <summary> /// Retrieve the properties of the server from the database. /// </summary> /// <param name="Database">Supplies the database connection to use for /// queries, if required. The active rowset may be consumed.</param> public void PopulateFromDatabase(IALFADatabase Database) { Database.ACR_SQLQuery(String.Format( "SELECT `Name`, `IPAddress`, `IsPublic` FROM `servers` WHERE `ID` = {0}", ServerId)); if (!Database.ACR_SQLFetch()) { throw new ApplicationException("Failed to populate data for server " + ServerId); } ServerName = Database.ACR_SQLGetData(0); SetHostnameAndPort(Database.ACR_SQLGetData(1)); Public = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(2)); }
/// <summary> /// Retrieve the properties of the character from the database. /// </summary> /// <param name="Database">Supplies the database connection to use for /// queries, if required. The active rowset may be consumed.</param> public void PopulateFromDatabase(IALFADatabase Database) { Database.ACR_SQLQuery(String.Format( "SELECT `Name`, `PlayerID`, `IsOnline`, `Location` FROM `characters` WHERE `ID` = {0}", CharacterId)); if (!Database.ACR_SQLFetch()) { throw new ApplicationException("Failed to populate data for character " + CharacterId); } CharacterName = Database.ACR_SQLGetData(0); PlayerId = Convert.ToInt32(Database.ACR_SQLGetData(1)); IsOnline = GameWorldManager.ConvertToBoolean(Database.ACR_SQLGetData(2)); LocationString = Database.ACR_SQLGetData(3); }
private void Start() { Game.Hero = new Hero() { Name = "TestHero" }; Game.Hero.Reset(); // Add some cards to the hero's deck Game.Hero.Deck.Add(new WildStrike()); List <IEnemyInstance> enemies = new List <IEnemyInstance> { new Enemy_TestDummy(), new Enemy_Skeleton(), new Enemy_Zombie() }; GameWorldManager world = new GameWorldManager(Game.Hero, enemies); world.Reset(Game.Hero, enemies); world.EventManager.OnNewLogMessage += EventManager_OnNewLogMessage; world.EventManager.OnPlayerDamageTaken += EventManager_OnPlayerDamageTaken; world.CardManager.FillDeck(); world.CardManager.CalculateEnergyCosts(); world.CardManager.DrawFirstHand(); listBoxCards.DisplayMember = "Name"; foreach (var managerAvailableBaseCard in world.CardManager.AvailableBaseCards) { this.listBoxCards.Items.Add(managerAvailableBaseCard); } listBoxCards.DisplayMember = "Name"; foreach (var managerAvailableBaseCard in world.CardManager.AvailableBaseCards) { this.listBoxCards.Items.Add(managerAvailableBaseCard); } listBoxCards.DisplayMember = "Name"; foreach (var enemy in world.EnemyManager.Enemies) { this.listBoxEnemy.Items.Add(enemy); } }
public GameEntity CreateGameEntity(GameWorldManager world, Vector3 scale, GameEntityParameters parameters) { GameEntity obj = new GameEntity(); obj.Init(); obj.Flags = Flags; Vector2 scale2D = new Vector2(scale.X, scale.Y); GameEntityCreatePhysics(obj, scale2D); GameEntityCreateSceneNodes(obj, scale, parameters != null ? parameters.SceneNodeParameters : null); GameEntityCreateControllers(obj); obj.Prefab = this; obj.Scale = scale; return(obj); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { GameObject aContributionPanel = ourGWM.createObject("UI/ContributionPanel"); aContributionPanel.name = "ContributionPanel"; aContributionPanel.transform.SetParent(GameObject.Find("UICanvas").transform); aContributionPanel.transform.localPosition = new Vector3(0, 0, 0); aContributionPanel.transform.FindChild("ExitButton").GetComponent<Button>().onClick.AddListener(() => GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().contributionExitButton_Clicked()); aContributionPanel.transform.FindChild("ContributeButton").GetComponent<Button>().onClick.AddListener(() => GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().contributionButton_Clicked()); aContributionPanel.transform.FindChild("NameLabel").GetComponent<Text>().text = anObjectIn.GetUtfString("Name"); aContributionPanel.transform.FindChild("LevelLabel").GetComponent<Text>().text = "(Level " + anObjectIn.GetInt("CenterNodeLevel").ToString() + ")"; aContributionPanel.transform.FindChild("CurrentContributionLabel").GetComponent<Text>().text = anObjectIn.GetInt("Contribution").ToString(); aContributionPanel.transform.FindChild("ContributionCapTotalLabel").GetComponent<Text>().text = anObjectIn.GetInt("ContributionCap").ToString(); aContributionPanel.transform.FindChild("ContributionPB").GetComponent<Scrollbar>().size = (float)anObjectIn.GetInt("CurrentTNL") / (float)anObjectIn.GetInt("TotalTNL"); aContributionPanel.transform.FindChild("ContributionPB").FindChild("ContributionText").GetComponent<Text>().text = anObjectIn.GetInt("CurrentTNL").ToString() + " / " + anObjectIn.GetInt("TotalTNL").ToString(); aContributionPanel.transform.FindChild("CurrentFoodLabel").GetComponent<Text>().text = anObjectIn.GetInt("CurrentFood").ToString(); //Switch Cursor Mode Camera.main.GetComponent<CameraController>().setCursorVisible(true); }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { Debug.Log("Server spawning player."); float[] locationArray = anObjectIn.GetFloatArray("Location"); float aRotation = anObjectIn.GetFloat("Rotation"); string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(anObjectIn.GetBool("IsLocal")) { GameObject aLocalPlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aLocalPlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aLocalPlayer.transform.rotation = Quaternion.identity; // Since this is the local player, lets add a controller and fix the camera aLocalPlayer.AddComponent<LocalPlayerController>(); aLocalPlayer.AddComponent<InputController>(); ourGWM.setLPC(aLocalPlayer.GetComponent<LocalPlayerController>()); ourGWM.getLPC().SetName(aCharacterName); aLocalPlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; GameObject cameraAttach = new GameObject(); cameraAttach.transform.parent = aLocalPlayer.transform; cameraAttach.transform.localPosition = new Vector3(1f, 2.5f, 1.0f); cameraAttach.name = "Camera Target"; Camera.main.transform.parent = cameraAttach.transform; Camera.main.GetComponent<CameraController>().setTarget(cameraAttach); Camera.main.GetComponent<CameraController>().setCursorVisible(false); } else if(!anObjectIn.GetBool("IsLocal")) { GameObject aRemotePlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aRemotePlayer.name = "GameCharacter_" + aCharacterName; aRemotePlayer.AddComponent<RemotePlayerController>(); aRemotePlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aRemotePlayer.GetComponent<RemotePlayerController>().SetRotation(aRotation); aRemotePlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; //Add Newly spawned player to Dictionary ourGWM.getPlayerDictionary().Add(aCharacterName, aRemotePlayer); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { Debug.Log("Inventory Update Recieved"); int[] iDArray = anObjectIn.GetIntArray("IDArray"); int[] itemArray = anObjectIn.GetIntArray("ItemIDArray"); int[] quantityArray = anObjectIn.GetIntArray("QuantityArray"); string[] nameArray = anObjectIn.GetUtfStringArray("NameArray"); string[] descriptionArray = anObjectIn.GetUtfStringArray("DescriptionArray"); string[] locationArray = anObjectIn.GetUtfStringArray("SubLocationArray"); bool reopenInventory = false; if(GameObject.Find("InventoryPanel") != null) { GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().openInventory(); reopenInventory = true; } if(itemArray.Length != quantityArray.Length) { Debug.Log("Item array and quantity array are not the same size."); } int iPos = 0; foreach (int ID in iDArray) { //If the inventory already has this item in it, simply update its data. if(ourGWM.getLPC().getInventory().ContainsKey(ID)) { ourGWM.getLPC().getInventory()[ID].updateItemData(itemArray[iPos], quantityArray[iPos], nameArray[iPos], descriptionArray[iPos], locationArray[iPos]); } else if(!ourGWM.getLPC().getInventory().ContainsKey(ID)) { ourGWM.getLPC().getInventory().Add(ID, new Item(ID, itemArray[iPos], quantityArray[iPos], nameArray[iPos], descriptionArray[iPos], locationArray[iPos])); } iPos++; } if(reopenInventory) { GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().openInventory(); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string[] types = anObjectIn.GetUtfStringArray("Type"); int[] levels = anObjectIn.GetIntArray("Level"); string[] location = anObjectIn.GetUtfStringArray("Location"); for(int i = 0; i < levels.Length; i++) { GameObject aNode; if(levels[i] == 0) { aNode = ourGWM.createObject("Prefabs/Settlements/WoodSign"); } else { aNode = ourGWM.createObject("Prefabs/Settlements/" + types[i] + "/" + levels[i].ToString()); } aNode.name = "Node_" + types[i] + "_" + levels[i]; aNode.transform.position = new Vector3(Convert.ToSingle(location[i].Split(',')[0]), Convert.ToSingle(location[i].Split(',')[1]), Convert.ToSingle(location[i].Split(',')[2])); aNode.transform.rotation = new Quaternion(0, Convert.ToSingle(location[i].Split(',')[3]), 0, 0); } }
private void Start() { // Helping garbage collector if there are any previous // GameWorldManager referenced Instance = null; // The instance will be replaced each time a new world is // loaded so that basic game world attributes can be used // again Instance = this; _equipments = new List <WeaponItem>(); _consumables = new List <ConsumableItem>(); _coins = new List <ConsumableItem>(); _requestItemDrops = new Queue <ItemDropInfo>(); // Loop for storing all equipment items for (int i = 0; i < Equipments.childCount; i++) { _equipments.Add(Equipments.GetChild(i).GetComponent <WeaponItem>()); } // Loop for storing all consumable items for (int i = 0; i < Consumables.childCount; i++) { _consumables.Add(Consumables.GetChild(i).GetComponent <ConsumableItem>()); } // Loop for storing all coin items for (int i = 0; i < Coins.childCount; i++) { _coins.Add(Coins.GetChild(i).GetComponent <ConsumableItem>()); } _isProcessing = false; }
public bool CanUseOverridable(GameWorldManager gameWorldManager, List <IEnemyInstance> targets, List <ICardInstance> cardTargets) { return(true); }
public int CalculateDamageOverridable(GameWorldManager gameWorldManager, int baseDamage, IEnemyInstance target) { return(baseDamage); }
/// <summary> /// Construct a new GamePlayer object. /// </summary> public GamePlayer(GameWorldManager WorldManager) { this.WorldManager = WorldManager; this.Characters = new List <GameCharacter>(); this.OnlineCharacter = null; }
// Use this for initialization void Start() { SFServer = SmartFoxConnection.Connection; ourGWM = GameObject.Find("SceneScriptsObject").GetComponent<GameWorldManager>(); ourRCM = GameObject.Find("SceneScriptsObject").GetComponent<RayCastManager>(); ChatTB = GameObject.Find("ChatTB").GetComponent<InputField>(); ChatContent = GameObject.Find("ChatContent"); ChatTextLabel = new List<GameObject>(); rayCastLabel = GameObject.Find("RayCastLabel"); rayCastLabel.SetActive(false); ChatTBisFocused = false; inventoryOpen = false; }
public int CalculateCostOverridable(GameWorldManager gameWorldManager, ICardInstance cardInstance) { return(Cost); }
/// <summary> /// Create a new GameEventQueue. /// </summary> /// <param name="WorldManager">Supplies the associated WorldManager /// object.</param> public GameEventQueue(GameWorldManager WorldManager) { this.WorldManager = WorldManager; }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { GameUI ourGameUI = GameObject.Find("SceneScriptsObject").GetComponent<GameUI>(); ourGameUI.processChat(anObjectIn.GetUtfString("ChatText")); }