private void AddController(XboxController controller) { int id = ((int)controller) - 1; // If there's a container empty, then add a player into it. (Not sure if we should do this, or just match the ID to the connected controller). GameObject containerGO = this.GetContainerByID(id).gameObject; if (containerGO) { // Getting the container and checking if it already has a player PlayerContainer container = containerGO.GetComponent <PlayerContainer>(); if (container.HasPlayer) { return; } // Setting up the container: container.ID = id; container.Controller = controller; container.HasPlayer = true; container.ToggleMech(); ++assignedPlayers; } else { Debug.Log("Can't find container."); } }
/// <summary> /// Load the view from from the provided JSON /// </summary> /// <param name="root">The JSON-object containing the serialized view</param> /// <param name="archive">Optional archive that the data points should be loaded from</param> /// <returns></returns> public async Task DeserializeView(JObject root, IDataStructure archive = null) { if (!await SerializableViewHelper.EnsureViewType(root, this, false, true)) { return; } var figures = XamarinHelpers.GetAllChildElements <FigureView>(PlayerContainer); foreach (var figure in figures) { figure.RemoveThisView(); } PlayerContainer.ViewerContext = ViewerContext; FigureView.DeserializationFailedWarned = false; if (root["player_container"] is JObject playerContainerJson) { await PlayerContainer.DeserializeView(playerContainerJson, archive); } if (root["playbar"] is JObject playbarJson) { await Playbar.DeserializeView(playbarJson, archive); } }
public IEnumerator EndScene(string scene, bool stopTime=true, bool setCheckpoint = true, bool stopTimeOnLoad=false) { loadingScene = true; if(stopTime) Time.timeScale = 0; playerGO = GameObject.FindWithTag ("Player"); if(playerGO!=null){ player = playerGO.GetComponent<PlayerContainer> (); player.playerInControl = false; } if(setCheckpoint) markCheckpoint (scene); // Make sure the texture is enabled. ren.enabled = true; if(loadingIcon!=null) loadingIcon.SetActive (true); // Start fading towards black. while(ren.color.a < 0.95f) { yield return null; FadeToBlack(); } AsyncOperation async = Application.LoadLevelAsync(scene); //Load scene yield return async; if(loadingIcon!=null) loadingIcon.SetActive (false); // If the texture is almost clear... while(ren.color.a > 0.001f) { FadeToClear(); yield return null; } ren.color = Color.clear; ren.enabled = false; if(playerGO!=null) player.playerInControl = true; if(!stopTimeOnLoad)Time.timeScale = 1; loadingScene = false; }
//[Command] void Remove() { bool successful = PlayerContainer.Remove(player); UIDebugScript.write(successful.ToString()); NetworkServer.Destroy(g_fighter); Debug.Log(player.ToString() + " quit the game."); }
/// <summary> /// Store the important parts of the objects in the provided JSON object (or a new one if the provided one is null) /// </summary> /// <param name="root">The JSON object the view should be stored in</param> /// <returns>The serialized JSON-view</returns> public JObject SerializeView(JObject root = null) { root = SerializableViewHelper.SerializeDefaults(root, this); root["player_container"] = PlayerContainer.SerializeView(); root["playbar"] = Playbar.SerializeView(); return(root); }
void OnTriggerEnter(Collider other) { if(other.tag == "Player") { inRange = true; data.nearInteractable = true; if(!autoSpeak && !npcObject) Speak(); p = other.GetComponent<PlayerContainer>(); } }
public PropertyBag(InfiniminerGame gameInstance) { // Initialize our network device. NetPeerConfiguration netConfig = new NetPeerConfiguration("InfiniminerPlus"); netConfig.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); netConfig.EnableMessageType(NetIncomingMessageType.ErrorMessage); netConfig.EnableMessageType(NetIncomingMessageType.DebugMessage); netConfig.EnableMessageType(NetIncomingMessageType.WarningMessage); netClient = new NetClient(netConfig); //netClient.SimulatedMinimumLatency = 0.1f; //netClient.SimulatedLatencyVariance = 0.05f; //netClient.SimulatedLoss = 0.1f; //netClient.SimulatedDuplicates = 0.05f; netClient.Start(); // Initialize engines. Engines = new Dictionary <string, Tuple <IEngine, Type> >(); RegisterEngine(new BlockEngine(gameInstance), "blockEngine"); RegisterEngine(new InterfaceEngine(gameInstance), "interfaceEngine"); RegisterEngine(new PlayerEngine(gameInstance), "playerEngine"); RegisterEngine(new SkyplaneEngine(gameInstance), "skyplaneEngine"); RegisterEngine(new ParticleEngine(gameInstance), "particleEngine"); PlayerContainer = new PlayerContainer(); SettingsContainer = new SettingsContainer(); ChatContainer = new ChatContainer(); TeamContainer = new TeamContainer(); TeamContainer.BeaconList = new Dictionary <Vector3, Beacon>(); PlayerList = new Dictionary <uint, Player>(); // Create a camera. PlayerContainer.PlayerCamera = new Camera(gameInstance.GraphicsDevice); UpdateCamera(); // Load sounds. if (!gameInstance.NoSound) { soundList[InfiniminerSound.DigDirt] = gameInstance.Content.Load <SoundEffect>("sounds/dig-dirt"); soundList[InfiniminerSound.DigMetal] = gameInstance.Content.Load <SoundEffect>("sounds/dig-metal"); soundList[InfiniminerSound.Ping] = gameInstance.Content.Load <SoundEffect>("sounds/ping"); soundList[InfiniminerSound.ConstructionGun] = gameInstance.Content.Load <SoundEffect>("sounds/build"); soundList[InfiniminerSound.Death] = gameInstance.Content.Load <SoundEffect>("sounds/death"); soundList[InfiniminerSound.CashDeposit] = gameInstance.Content.Load <SoundEffect>("sounds/cash"); soundList[InfiniminerSound.ClickHigh] = gameInstance.Content.Load <SoundEffect>("sounds/click-loud"); soundList[InfiniminerSound.ClickLow] = gameInstance.Content.Load <SoundEffect>("sounds/click-quiet"); soundList[InfiniminerSound.GroundHit] = gameInstance.Content.Load <SoundEffect>("sounds/hitground"); soundList[InfiniminerSound.Teleporter] = gameInstance.Content.Load <SoundEffect>("sounds/teleport"); soundList[InfiniminerSound.Jumpblock] = gameInstance.Content.Load <SoundEffect>("sounds/jumpblock"); soundList[InfiniminerSound.Explosion] = gameInstance.Content.Load <SoundEffect>("sounds/explosion"); soundList[InfiniminerSound.RadarHigh] = gameInstance.Content.Load <SoundEffect>("sounds/radar-high"); soundList[InfiniminerSound.RadarLow] = gameInstance.Content.Load <SoundEffect>("sounds/radar-low"); soundList[InfiniminerSound.RadarSwitch] = gameInstance.Content.Load <SoundEffect>("sounds/switch"); } }
private void PlayerConnected(BoltConnection connection) { BoltConsole.Write("PlayerConnected", Color.yellow); PlayerContainer PC = new PlayerContainer(Random.Range(1000000, 9999999).ToString(), connection); players.Add(PC); RebuildRosterList(); }
private void CreateInstance() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } }
public string GetPlayerIdFromName(string playerName) { string link = "https://masterbattlerite.com/"; masterBattleriteClient = new RestClient(new Uri(link)); var req = new RestRequest($"profile/{playerName}/lookup"); var response = masterBattleriteClient.Execute(req); var json = response.Content; PlayerContainer container = JsonConvert.DeserializeObject <PlayerContainer>(json); return(container.Player.UserId); }
public void OnGameOver() { //Do something when time is over var min = result.result.OrderBy(kvp => kvp.Value).First(); var minKey = min.Key; string winner = PlayerContainer.Get(minKey).getName(); server.SendResult(winner); result.SetWinner(winner); SceneManager.LoadScene("ResultScene"); RpcOnGameOver(winner); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here arial = this.Content.Load <SpriteFont>("Arial"); this.rTater = new Rotator(348, 202); baseJeep = Texture2d.FromFileName(this.GraphicsDevice, "Content/Jeep.png"); var jeepFrames = FramesGenerator.GenerateFrames(new FrameInfo(243, 243), new Dimensions(baseJeep.Width, baseJeep.Height)); player = new PlayerContainer(this.spriteBatch, this.baseJeep, new Character(jeepFrames), this.rTater, player1Keys, new Point(100, 125)); }
/// <summary> /// Sends out the result messages based on the teamResult. /// </summary> /// <param name="teamResult"> /// Lose = -1; /// Tie = 0; /// Win = 1; /// </param> void PropagateResultMessages(PlayerContainer[] players, int teamResult) { switch(teamResult) { case -1: for(int i=0; i<players.Length; i++) { if(players[i] != null && players[i].m_player != Network.player) { Debug.Log ("Message sent to: " + players[i].m_player); networkView.RPC("InitLoseSequence", players[i].m_player); } else if (players[i] != null && players[i].m_player == Network.player) { Debug.Log ("Message sent to: server"); StartCoroutine("ClosingSequence", "YOU LOSE!"); } } /*foreach(PlayerContainer p in players) { networkView.RPC ("InitLoseSequence", p.m_player); }*/ break; case 0: for(int i=0; i<players.Length; i++) { if(players[i] != null && players[i].m_player != Network.player) { Debug.Log ("Message sent to: " + players[i].m_player); networkView.RPC("InitTieSequence", players[i].m_player); } else if (players[i] != null && players[i].m_player == Network.player) { Debug.Log ("Message sent to: server"); StartCoroutine("ClosingSequence", "DRAW!"); } } /*foreach(PlayerContainer p in players) { networkView.RPC ("InitTieSequence", p.m_player); }*/ break; case 1: for(int i=0; i<players.Length; i++) { if(players[i] != null && players[i].m_player != Network.player) { Debug.Log ("Message sent to: " + players[i].m_player); networkView.RPC("InitWinSequence", players[i].m_player); } else if (players[i] != null && players[i].m_player == Network.player) { Debug.Log ("Message sent to: server"); StartCoroutine("ClosingSequence", "YOU WIN!"); } } /*foreach(PlayerContainer p in players) { networkView.RPC ("InitWinSequence", p.m_player); }*/ break; } Debug.Log ("Messages Sent"); }
private void PlayerDisconnected(BoltConnection connection) { BoltConsole.Write("PlayerDisconnected", Color.yellow); PlayerContainer PC = players.First(x => x.Connection == connection); PC.InGame = false; if (PC.HasPlayer) { BoltNetwork.Destroy(PC.Player); } RebuildRosterList(); }
public void SetUp() { _subEventContext = Substitute.For <IEventContext>(); _subEventContext.GetEvent(EventKey.FrameUpdate).Returns(new TofuEvent(EventKey.FrameUpdate)); _subServiceContext = TestUtilities.BuildSubServiceContextWithServices(new Dictionary <string, object> { { "IEventContext", _subEventContext } }); _playerContainer = new PlayerContainer(); _playerContainer.Build(); _playerContainer.BindServiceContext(_subServiceContext); _playerContainer.ResolveServiceBindings(); _playerContainer.Initialize(); }
// Use this for initialization void Start() { master = GameObject.Find ("Master").GetComponent<PlayerContainer>(); coin = GameObject.Find ("Coin_1"); collectCount = 0; tries = 0; score = GameObject.Find ("Score"); do { tmp.Set (UnityEngine.Random.Range (-115, 75),coin.transform.position.y,UnityEngine.Random.Range (-100, 86)); result = Physics.OverlapSphere (tmp, 2f); tries++; } while(result.Length != 0 && tries < 5); coin.transform.position = tmp; startTime = DateTime.Now; pushedToDatabase = false; }
// Use this for initialization void Start() { master = GameObject.Find ("Master").GetComponent("PlayerContainer") as PlayerContainer; player = GameObject.Find ("Player"); titleMenu = GameObject.Find ("TitleMenu"); inField = titleMenu.GetComponentInChildren<InputField> (); if (master.Player != null) { inField.text = master.Player.name; } if (master.race) { GameObject.Find("RawImage").SetActive(false); } if (Application.loadedLevelName == "FoodCourt") { GameObject.Find("RawImage").transform.position = new Vector3 (Screen.width - 70, Screen.height - 50, 0); } }
// Loops through the container list and returns the first container without a player. private PlayerContainer FindNextEmptyContainer() { for (int i = 0; i < playerContainers.Count; ++i) { // Checking if the container has a player, and skipping the return if it does: PlayerContainer container = playerContainers[i].GetComponent <PlayerContainer>(); if (container.HasPlayer) { continue; } // Returning the empty container. return(container); } // Returns null if no empty container is found. return(null); }
/* Instantiate player GameObjects in * the scene and init their data. */ private List <PlayerData> InstantiatePlayerObjects() { List <PlayerData> playerDataList = new List <PlayerData>(); /* Possible player control types. */ GameObject human = Resources.Load <GameObject> (ResourcePath.playerHuman); GameObject ai = Resources.Load <GameObject> (ResourcePath.playerAI); playerDataList.Clear( ); for (int id = 0; id < playerControlType.Count; id++) { GameObject player; bool isHuman; string playerName = ""; if (playerControlType[id]) { isHuman = true; player = MonoBehaviour.Instantiate <GameObject> (human); playerName = "Human"; } else { isHuman = false; player = MonoBehaviour.Instantiate <GameObject> (ai); playerName = "The AI"; } if (player != null) { PlayerContainer.AttachToTransformAsChild(player); playerDataList.Add(new PlayerData(player, player.GetComponent <Player> ( ), id, isHuman, playerName)); ++currentGamePlayerCount; } else { Debug.Log("[PlayerConfiguration][InstantiatePlayerObjects] GameObject 'player' is null "); } } //Resources.UnloadAsset ( human ); //Resources.UnloadAsset ( ai ); return(playerDataList); }
// Use this for initialization void Start() { master = GameObject.Find ("Master").GetComponent<PlayerContainer> (); this.participants = new List<Participant> (); participants.Add(new Participant(GameObject.Find("Player"))); GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Participant"); for (int j = 0; j < gameObjects.Length; j++) { Participant temp = new Participant(gameObjects[j]); participants.Add(temp); } for (int i = 0; i < participants.Count; i++) { Debug.Log(participants[i].gameObject.tag.ToString()); } winner = 0; raceOver = false; pushedToDatabase = false; startTime = DateTime.Now; }
void CmdAdd(bool host) { GameInputManager i = FindObjectOfType <GameInputManager> (); isHost = i.isHost; g_fighter = (GameObject)Instantiate(Mario); //g_fighter = (GameObject)Instantiate (Inkachu); fighter = g_fighter.GetComponent <Fighter> (); player = PlayerContainer.Add(fighter); FindObjectOfType <ResultContainer> ().Add(player); this.gameObject.name = player.ToString(); fighter.SetPlayer(player); fighter.setName(player.ToString()); fighter.SetInput(this); fighter.SetLocalClient(isHost); NetworkServer.Spawn(g_fighter); Debug.Log(PlayerContainer.Get(player).getName() + " joined the game"); RpcAdd(player); }
public async Task <bool> VerifySteam64IDAsync(long steamID) { using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(SteamPlayerAPI + keyParameter + steamAPIKey + steamIDs + steamID)) using (HttpContent content = response.Content) { bool foundUser = false; string result = await content.ReadAsStringAsync(); PlayerContainer player = JsonConvert.DeserializeObject <PlayerContainer>(result); if (player.response.Player.Count() > 0) { foundUser = true; } return(foundUser); } }
private void RemoveController(XboxController controller) { int id = ((int)controller) - 1; GameObject containerGO = this.GetContainerByID(id).gameObject; if (containerGO) { PlayerContainer container = containerGO.GetComponent <PlayerContainer>(); if (!container.HasPlayer) { return; } container.ID = -1; container.Controller = ((XboxController)0); container.HasPlayer = false; container.ToggleMech(); --assignedPlayers; } else { Debug.Log("Can't find container."); } }
// Use this for initialization void Start() { pc = GameObject.Find ("Master").GetComponent ("PlayerContainer") as PlayerContainer; player = GameObject.Find("Player"); rigidBody = player.GetComponent<Rigidbody>(); titleMenu = GameObject.Find ("TitleMenu"); arrow = GameObject.Find ("Arrow"); if (Application.loadedLevelName != "TitleScreen") { titleMenu.SetActive(false); if(Application.loadedLevelName == "FoodCourt" && pc.race) { Vector3 temp = new Vector3(55.26f, player.transform.position.y, -7.3f); player.transform.position = temp; arrow.SetActive(false); GameObject.Find ("Coin_1").SetActive(false); } } paused = false; canvas = GameObject.Find ("Canvas"); text = canvas.GetComponentInChildren<Text> (); race = Race.Instance (); }
// Use this for initialization void Start() { obstacles = GameObject.Find ("Obstacles"); pc = GameObject.Find ("Master").GetComponent("PlayerContainer") as PlayerContainer; if (!pc.race) { Collider[] result; temp = new Vector3 (); int tries; foreach (Transform child in obstacles.transform) { tries = 0; do { temp.x = Random.Range (-112, 85); temp.y = child.position.y; temp.z = Random.Range (-105, 93); result = Physics.OverlapSphere (temp, 10f); tries++; } while(result.Length != 0 && tries < 5); child.position = temp; } } else { obstacles.SetActive(false); } }
void seePlayer(Collider other) { if(player!=null) pc = player.GetComponent<PlayerContainer>(); // Create a vector from the enemy to the player and store the angle between it and forward. Vector3 direction = other.transform.position - transform.position; float angle = Vector3.Angle(direction, transform.forward); if (angle < fieldOfViewAngle) { RaycastHit hit; // ... and if a raycast towards the player hits something... if(Physics.Raycast(transform.position + transform.up, direction.normalized, out hit, sightRange)) { Debug.DrawLine(transform.position, hit.point, Color.red); // ... and if the raycast hits the player... if (hit.collider.gameObject.tag == "Player") { // ... the player is in sight. if(pc.playerHiddenInCoffin() && !playerInSight) { if(!checkedCoffin) { Vector3 midPoint = Vector3.Lerp(player.transform.position, transform.position,0.5f); playerLastSighting = midPoint; checkedCoffin = true; } } else if(canSee) { playerInSight = true; checkedCoffin = false; } //Debug.Log ("I SEE YOU!"); // Set the last global sighting is the players current position. if(player == null || player.active == false) { //IN CASE PLAYER SWITCHES player = GameObject.FindWithTag("Player").transform; playerAnimator = player.GetComponent<Animator>(); } if(canSee && !pc.playerHiddenInCoffin()) { playerLastSighting = player.transform.position; cautionTimer = 0; //Reset caution timer since player's busted } } else playerInSight = false; } else playerInSight = false; } else playerInSight = false; //Exception: Get in the "personal bubble" float distanceFromPlayer = Vector3.Distance(player.transform.position, transform.position); if (distanceFromPlayer <= 2.5f) { // ... the player is in sight. playerInSight = true; //Debug.Log ("I SEE YOU!"); // Set the last global sighting is the players current position. if(player == null || player.active == false) { //IN CASE PLAYER SWITCHES player = GameObject.FindWithTag("Player").transform; playerAnimator = player.GetComponent<Animator>(); } playerLastSighting = player.transform.position; cautionTimer = 0; //Reset caution timer since player's busted } }
void startWalking() { player = GameObject.FindWithTag ("Player").GetComponent<PlayerContainer> (); player.StopAllCoroutines (); StartCoroutine (walk()); }
public void CreatePlayer(GameObject at) { PlayerContainer = _assetProvider.Instantiate(AssetPath.PlayerPath, at.transform.position, at.transform.rotation).GetComponent <PlayerContainer>(); }
public void UpdateMana(PlayerContainer[] team) { for(int i=0; i<team.Length; i++) { if(team[i] != null) { team[i].m_mana.Update(); } } }
/// <summary> /// Fill the player list with all of the players currently in the game. /// This function is to be called after players have moved past the lobby. /// Typically, the best object to call this function would be the scene manager /// as it has access to data about which players are actively player and which /// are spectators. /// </summary> public void Initialize(params NetworkPlayer[] players) { if(Network.isServer) { // Create all player containers for(int i=0; i<players.Length; i++) { PlayerContainer newPlayer = new PlayerContainer(); newPlayer.m_player = players[i]; newPlayer.m_avatar = null; newPlayer.m_buffs = new BuffContainer(); newPlayer.m_health = new Health(); newPlayer.m_health.SetHealth(DEFAULT_HEALTH); newPlayer.m_mana = new Mana(); newPlayer.m_mana.SetMana(DEFAULT_MANA); newPlayer.m_mana.SetRegenRate(DEFAULT_MANA_REGEN); newPlayer.m_team = i%2; this.players.Add(newPlayer); } // Decide teams at this time, this is only a temporary solution teamOne = new int[players.Length/2 + (players.Length%2==1 ? 1 : 0)]; teamTwo = new int[players.Length/2]; for(int i=0; i<players.Length; i++) { int j=0; if(i%2 == 0) { teamOne[j] = i; } else { teamTwo[j] = i; j++; } } } }
void Awake() { animator = model.GetComponent<Animator>(); player = GetActivePlayer.getActivePlayer().GetComponent<PlayerContainer>(); }
public static void AttachToTransformAsChild(GameObject playerGameObject) { PlayerContainer container = FindObjectOfType<PlayerContainer> ( ); playerGameObject.transform.SetParent ( container.transform ); }
private void TreeView_DataPointTapped(object sender, IDataPoint dataPoint) { PlayerContainer.DataPointSelected(dataPoint, ViewerContext); }
/// <summary> /// Filialo konstruktorius su parametrais /// </summary> /// <param name="race">Rasė</param> /// <param name="town">Miestas</param> public Branch(string race, string town) { Race = race; Town = town; Players = new PlayerContainer(); }
void OnApplicationQuit() { PlayerContainer.Remove(player); Debug.Log(player.ToString() + " quit the game."); }
private void OnPlayerCreation(object sender, EventPlayerCreationArgs e) { target = e.player.GetComponentInChildren <PlayerContainer>(); }
} //Veikėjų konteineris /// <summary> /// Filialo konstruktorius /// </summary> public Branch() { Players = new PlayerContainer(); }