public bool StartCombat(DamageDealerComponent damageDealer) { if (!_readyToCombat) { return(false); } PlayerStructure playerStructure = _playerState.GetActivePlayerStructure(); InteractableComponent interactableComponent = playerStructure.GetInteractableComponent(); if (interactableComponent is null) { return(false); } if (!interactableComponent.CheckIfCanAtack()) { return(false); } damageDealer.event_AlertAttack.Invoke(); interactableComponent.SetInteractableState(EnumInteractableState.Atack, this.GetInstanceID()); // Go to the correct position to attack playerStructure.GetMovementMouseComponent().ObjectGoTo(this.transform.position, _colliderToStopMovement.GetInstanceID()); return(true); }
public void Btn_EatFlower() { PlayerStructure playerStructure = _playerState.GetActivePlayerStructure(); InteractableComponent interactableComponent = playerStructure.GetInteractableComponent(); this.IniciateSomeInteraction(EnumInteractableState.EatFlower, playerStructure, interactableComponent); }
public void playerSetup(SpawnSpot thisSpawn) { GameObject p = null; int playerID = PhotonNetwork.player.ID; if (currLevel.spawnStructure != null) { GameObject g = Instantiate(currLevel.spawnStructure, thisSpawn.getSpawnPoint(), thisSpawn.transform.rotation, currLevel.StructuresTransform); g.name = "PlayerSpawn: " + Persistent.thisPersist.Username + playerID; PlayerStructure s = g.GetComponent <PlayerStructure>(); if (s != null) { s.isLocal = true; currLevel.structures.Add(s); p = PhotonNetwork.Instantiate(playerInstantiate.name, s.spawnPosition.position, s.spawnPosition.rotation, 0, null); myPlayer = p.GetComponent <player>(); view.RPC("setStructure", PhotonTargets.Others, s.GenerateJSON().ToString()); myPlayer.spwanRoom = s; myPlayer.spwanPos = s.spawnPosition; } else { Debug.Log("The currLevel spawnStructure does not have a player sturcture comp. attached"); return; } } else { p = PhotonNetwork.Instantiate(playerInstantiate.name, thisSpawn.transform.position, thisSpawn.transform.rotation, 0, null); myPlayer = p.GetComponent <player>(); myPlayer.spwanPos = thisSpawn.transform; } myPlayer.playerID = playerID; myPlayer.name = PhotonNetwork.player.NickName = Persistent.thisPersist.Username; // myPlayer.transform.FindChild ("Graphics").GetComponent<Renderer> ().material.color = player.getPlayerColour (playerID); p.layer = LayerMask.NameToLayer(PlayerLayer); myPlayer.animModel.layer = LayerMask.NameToLayer(GhostLayer); p.GetComponent <Rigidbody>().isKinematic = false; PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { "Kills", 0 }, { "Placed", 0 }, { "NewItemsPicked", 0 }, { "Destroyed", 0 }, { "Deaths", 0 } }); if (doObjectives) { ObjectivesManeger.thisM.Initialize(); } NetworkEnable(); view.RPC("updatePlayers", PhotonTargets.AllBuffered, myPlayer.thisView.viewID, myPlayer.name, myPlayer.playerID); }
public int CreateNewPlayerSlotCompoennt(PlayerStructure playerStructure) { ActivePlayerSlotComponent nextSlot = GameObject.Instantiate(_ActivePlayerSlotPrefab, this.transform).GetComponent <ActivePlayerSlotComponent>(); nextSlot.SetPlayerStructure(playerStructure); _playerSlotComponentList.Add(nextSlot); return(nextSlot.GetInstanceID()); }
public void AddPlayerStrucute(PlayerStructure player) { if (_playerStructueList is null) { _playerStructueList = new List <PlayerStructure>(); } _playerStructueList.Add(player); }
private void StartPlantingProccess(PlayerStructure playerStrucute, InteractableComponent interactableComponent) { if (_plantSpotState != EnumPlantSpotState.Empty) { return; } this.IniciateSomeInteraction(EnumInteractableState.Plant, playerStrucute, interactableComponent); }
private void CmdkillPlayer(int id) { CmdIncrementKills(); Player player = PlayerStructure.getInstance().getPlayer(id); player.health = 0; }
public override void OnStartServer() { base.OnStartServer(); PlayerStructure.newInstance(); isServer = true; }
public static PlayerStructure getInstance() { if (instance == null) { PlayerStructure.newInstance(); } return(instance); }
public void SetNewPlayerStrucutre(PlayerStructure playerStructure) { if (!_playerStrucutreList.Any(e => e.IsActive) && playerStructure.IsMainPlayer) { playerStructure.ActivatePlayerStructure(true); } _playerStrucutreList.Add(playerStructure); }
private void CmdkillPlayer(int id) { //playerNetwork.CmdIncrementKills(); Player player = PlayerStructure.getInstance().getPlayer(id); player.health = 0; //player.playerNetwork.CmdIncrementDeaths(); }
private void IniciateSomeInteraction(EnumInteractableState interactionState, PlayerStructure playerStructure, InteractableComponent interactableComponent) { if (interactableComponent is null) { return; } interactableComponent.SetInteractableState(interactionState, this.GetInstanceID()); playerStructure.GetMovementMouseComponent().ObjectGoTo(this.transform.position, _radioToInteract); }
public static Player[] getRankings() { PlayerStructure structure = PlayerStructure.getInstance(); Player[] liste = (Player[])structure.getListe().Clone(); Array.Sort(liste); return(liste); }
public PlayerStructure GetActivePlayerStructure() { PlayerStructure playerStructure = _playerStrucutreList.FirstOrDefault(e => e.IsActive); if (playerStructure is null) { playerStructure = _playerStrucutreList.FirstOrDefault(e => e.IsMainPlayer); } return(playerStructure); }
protected override void SetInitialValues() { _playerStructure = this.GetComponent <PlayerStructure>(); _inputManager = GameObject.FindObjectOfType <InputManager>(); _poopList = Resources.LoadAll <PoopScriptable>("ScriptableObjects/Poops"); _stomachUIComponent = GameObject.FindObjectOfType <StomachUIComponent>(); StomachItemList = new List <StomachItemDTO>(); _isPooping = false; _animator = this.GetComponent <Animator>(); _movementMouseComponent = this.GetComponent <MovementMouseComponent>(); _animatorVariables = new StomachAnimatorVariables(); _playerStateManager = GameObject.FindObjectOfType <PlayerStateManager>(); }
public void ActiveNewPlayerStructure(int playerStructureInstanceId) { foreach (PlayerStructure playerStructure in _playerStrucutreList) { playerStructure.ActivatePlayerStructure(false); } PlayerStructure activePlayerStructure = _playerStrucutreList.FirstOrDefault(e => e.GetInstanceID() == playerStructureInstanceId); if (activePlayerStructure != null) { activePlayerStructure.ActivatePlayerStructure(true); } }
public bool Interact() { PlayerStructure playerStructure = _playerState.GetActivePlayerStructure(); InteractableComponent interactableComponent = playerStructure.GetInteractableComponent(); if (interactableComponent is null) { return(false); } if (!interactableComponent.CanPlant && !interactableComponent.CanTakePlant && !interactableComponent.CanTakeSeed) { return(false); } ToggleInternalUIMenu(); StartPlantingProccess(playerStructure, interactableComponent); return(true); }
public static void LoadStructuresFromDatabase() { Structures.Clear(); using var connection = new SQLiteConnection(DatabaseManager.UserDataDbConnection); connection.Open(); try { using var sqLiteCommand = new SQLiteCommand("SELECT * from structures", connection); using var reader = sqLiteCommand.ExecuteReader(); while (reader.Read()) { try { var structure = new PlayerStructure { StructureId = (long)reader[0], Name = (string)reader[1], OwnerId = Convert.ToInt32((long)reader[2]), SolarSystemId = Convert.ToInt32((long)reader[3]), TypeId = Convert.ToInt32((long?)reader[4]), AddedBy = (long?)reader[5], AddedAt = (DateTime?)reader[6], Enabled = Convert.ToBoolean((long?)reader[7]) }; Structures.Add(structure); } catch (Exception) { // ignored } } } finally { connection.Close(); } }
// Use this for initialization private void Start() { if (isServer) { id = PlayerStructure.getInstance().addPlayer(this); playerName = "Player " + (id + 1); } else if (!hasAuthority) { addToPlayerStructure(id); } m_CharacterController = GetComponent <CharacterController>(); m_Camera = this.gameObject.GetComponentInChildren <Camera>(); m_OriginalCameraPosition = m_Camera.transform.localPosition; m_FovKick.Setup(m_Camera); m_HeadBob.Setup(m_Camera, m_StepInterval); m_StepCycle = 0f; m_NextStep = m_StepCycle / 2f; m_Jumping = false; m_MouseLook.Init(transform, m_Camera.transform); EventsManager.TriggerEvent(EventsManager.Events.somebodyDied); }
public static PlayerStructure newInstance() { instance = new PlayerStructure(); return(instance); }
public void RemoveOnePlayerStructure(PlayerStructure playerStructure) { _playerStrucutreList.Remove(playerStructure); }
public void RemovePlayerStructure(PlayerStructure player) { _playerStructueList.Remove(player); }
private void addToPlayerStructure(int i) { id = i; PlayerStructure.getInstance().addPlayerAtId(i, this); }
public void SetPlayerStructure(PlayerStructure playerStructure) { image.sprite = playerStructure.SpriteForActiveStatus; _currentPlayerStructure = playerStructure; }
public PlayerStructure GetPlayer(int PlayerId) { using (var context = new LoLEsportsDbContext()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { PlayerStructure data = new PlayerStructure(); Player player = context.Player.Where(i => i.PlayerId == PlayerId).FirstOrDefault(); if (player == null) { data.error = 1; data.message = "Player does not exist in the current database."; return(data); } Person person = context.Person.Where(i => i.PersonId == player.PersonId).FirstOrDefault(); if (person == null) { data.error = 1; data.message = "Player does not have an existing PersonID."; return(data); } data.error = 0; data.Age = person.Age; data.Biography = person.Biography; data.Hometown = person.Hometown; data.PersonName = person.PersonName; data.PlayerID = player.PlayerId; data.PlayerIGN = player.PlayerIgn; data.PlayerRole = player.PlayerRole; data.Quote = player.Quote; data.Salary = person.Salary; //Calculate scores int TotalKills = context.PlayerMatchRef.Where(i => i.PlayerId == player.PlayerId).Sum(x => x.PlayerKills); int TotalAssists = context.PlayerMatchRef.Where(i => i.PlayerId == player.PlayerId).Sum(x => x.PlayerAssists); int TotalScore = context.PlayerMatchRef.Where(i => i.PlayerId == player.PlayerId).Sum(x => x.PlayerScore); int TotalDeaths = context.PlayerMatchRef.Where(i => i.PlayerId == player.PlayerId).Sum(x => x.PlayerDeaths); player.TotalKills = TotalKills; player.TotalAssists = TotalAssists; player.TotalScore = TotalScore; player.TotalDeaths = TotalDeaths; context.Update(player); context.SaveChanges(); data.TotalAssists = TotalAssists; data.TotalDeaths = TotalDeaths; data.TotalKills = TotalKills; data.TotalScore = TotalScore; data.PlayerImage = player.PlayerImage; int TeamId = context.CompetitorTeamRef.Where(i => i.PlayerId == PlayerId).Select(x => x.TeamId).FirstOrDefault(); data.TeamName = context.Team.Where(i => i.TeamId == TeamId).Select(x => x.TeamName).FirstOrDefault(); data.TeamImage = context.Team.Where(i => i.TeamId == TeamId).Select(x => x.TeamLogo).FirstOrDefault(); data.TeamID = TeamId; dbContextTransaction.Commit(); return(data); } catch (Exception) { dbContextTransaction.Rollback(); PlayerStructure data = new PlayerStructure(); data.error = 1; data.message = "Database could not commit the transaction."; return(data); } } } }