// Use this for initialization void Start() { anim = gameObject.GetComponent<Animator>(); swordCollider = transform.GetComponentInChildren<SwordCollideDetector>(); attack1Button = new Command_Input.Attack_1(this); currentState = Player.State.Idle; }
void CheckStatus() { if (m_CurState == player.GetState()) { return; } else { m_CurState = player.GetState(); } switch (m_CurState) { case Player.State.Idle: m_ImagePlay.sprite = imgRun; break; case Player.State.Return: m_ButtonPlay.interactable = false; m_AudioSrc.Stop(); break; case Player.State.Starting: m_ImagePlay.sprite = imgIdle; m_AudioSrc.Play(); break; } }
/// <summary> /// Constructor for the <c>EventData_UnitStateChanged</c> class. /// </summary> /// <param name="unit">Reference to the unit.</param> /// <param name="newState">New <c>Player.State</c> for the unit.</param> public EventData_UnitStateChanged(Player unit, Player.State newState) { _eventType = EventManager.EventType_UnitStateChanged; _unit = unit; _newState = newState; }
// Use this for initialization void Start() { anim = gameObject.GetComponent <Animator>(); swordCollider = transform.GetComponentInChildren <SwordCollideDetector>(); attack1Button = new Command_Input.Attack_1(this); currentState = Player.State.Idle; }
public override void Update() { if (!Player.IsDead) { base.Update(); if (timeTackle <= 0 || !Player.IsGrounded) { Player.State stateToSwitch = Player.State.Idle; if (!Player.IsGrounded) { stateToSwitch = Player.State.JumpStopped; } else if (InputManager.GetButton(Button.Down)) { stateToSwitch = Player.State.Crouch; } machine.Switch((int)stateToSwitch); } else { timeTackle -= Game.DeltaTime; } if (Player.IsInvincible) { Player.OffsetHead = new Vector2(Player.Width / 10 - 3, Player.Height / 10 - 9); } } }
public PlayerState(Player.State state_, bool cloud, bool isLock_, int tmp) { state = state_; onCloud = cloud; isLock = isLock_; temp = tmp; }
public LizardEnemy(Vector2 spritePosition, float patrolXDist = 120, string spriteSheetName = "lizard", DrawManager.Layer drawLayer = DrawManager.Layer.Playground) : base(spritePosition, spriteSheetName, drawLayer) { sprite.scale = new Vector2(1.3f, 1.3f); speedWalk = 50f; speedRun = PlayScene.Player != null ? PlayScene.Player.Speed.X + 70 : 230f; SightRadius = 250f; IsTurningAround = false; animationSpeedIncrement = 0.15f; rangeAttack = SightRadius * 2f; Machine = new StateMachine(this); Machine.RegisterState((int)State.Patrol, new LizardPatrolState(new Tuple <float, float>(Position.X - patrolXDist, Position.X + patrolXDist))); Machine.RegisterState((int)State.Alert, new LizardAlertState()); Machine.RegisterState((int)State.Attack, new LizardAttackState()); Machine.Switch((int)State.Patrol); playerDieAnimationOnHitted = Player.State.DeathBurnt; smoke = new Smoke(Position, "smoke", DrawManager.Layer.Middleground); initialFlipX = FlipX; clipCry = AudioManager.GetAudioClip("lizard"); nextCry = 2f; }
public void OnPlayerRespawn(ref Player.State playerState, ref Vector3 position, ref Quaternion rotation) { SpawnPoint[] spawns = null; if (playerState.teamIndex == s_AttackTeam && m_AttackersBasePoint != null) { spawns = m_AttackersBasePoint.spawns; } else if (playerState.teamIndex == s_DefendTeam && m_DefendersBasePoint != null) { spawns = m_DefendersBasePoint.spawns; } // Spawn at capture point if possible if (spawns != null && spawns.Length > 0) { int l = spawns.Length; m_LastSpawnIdx = (m_LastSpawnIdx + 1) % l; var spawn = spawns[m_LastSpawnIdx]; position = spawn.transform.position; rotation = spawn.transform.rotation; } else { GameDebug.Log("Spawning at home base"); // Spawn at home base m_GameModeSystemServer.GetRandomSpawnTransform(playerState.teamIndex, ref position, ref rotation); } }
public void OnPlayerKilled(ref Player.State victim, ref Player.State killer) { if (killer.teamIndex != victim.teamIndex) { killer.score++; } }
private IEnumerator IncrementAvailableMoves(Player.State _state) { yield return(new WaitForSeconds(Constants.COOLDOWNS[_state])); m_availableMoves[_state]++; StartCoroutine(m_playerInfo.UpdateAction(_state, m_availableMoves[_state])); }
public void EnterGame() { m_ButtonPlay.interactable = true; // Вторым аргументом передаётся только поворот по Y. player.Init(spawnPoint.position, spawnPoint.rotation.eulerAngles.y, gameObject.transform); interactiveCamera.SetActive(true); m_CurState = player.GetState(); }
public Trap(Vector2 spritePosition, string spriteSheetName = "trapThorns", DrawManager.Layer layer = DrawManager.Layer.Middleground) : base(spritePosition, spriteSheetName, layer) { playerAnimDie = Player.State.DeathAngel; RigidBody = new RigidBody(spritePosition, this); RigidBody.SetCollisionMask((uint)PhysicsManager.ColliderType.Player); RigidBody.Type = (uint)PhysicsManager.ColliderType.Trap; //togliere se ci sono problemi con le spine }
/// <summary> /// Initializes a new instance of the <see cref="PlayerStateException"/> class with serialized data. /// </summary> /// <param name="info">The object that holds the serialized object data.</param> /// <param name="context">The contextual information about the source or destination.</param> protected PlayerStateException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info == null) { throw new ArgumentNullException("info"); } State = (Player.State)Enum.Parse(typeof(Player.State), info.GetString("State")); }
// Update is called once per frame public void Update() { if (nextState != currentState) { mapStates[currentState].OnStateExit(); mapStates[nextState].OnStateEnter(); currentState = nextState; } mapStates[currentState].Update(); }
private void handleInput() { if (Input.GetButtonDown(PlayerPrefs.GetString("Attack1","Fire2"))) attack1Button.execute(); if (Time.time > Attack_Time) { Attack_Num=0; currentState = Player.State.Idle; swordCollider.goAttack = false; anim.SetInteger("Attack1_Num", 0); } }
public IEnumerator UpdateAction(Player.State _state, int numActions) { if (m_availableMoves.ContainsKey(_state) && numActions <= m_availableMoves[_state].Count) { MakeVisible(numActions, m_availableMoves[_state]); yield return(null); } else { throw new Exception("invalid state/numActions passed"); } }
public void OnPlayerKilled(ref Player.State victim, ref Player.State killer) { if (killer.teamIndex != victim.teamIndex) { killer.score++; m_GameModeSystemServer.teams[killer.teamIndex].score++; } else if (victim.playerId == killer.playerId) { victim.score--; m_GameModeSystemServer.teams[victim.teamIndex].score--; } }
private void handleInput() { if (Input.GetButtonDown(PlayerPrefs.GetString("Attack1", "Fire2"))) { attack1Button.execute(); } if (Time.time > Attack_Time) { Attack_Num = 0; currentState = Player.State.Idle; swordCollider.goAttack = false; anim.SetInteger("Attack1_Num", 0); } }
public void UpdateIngame(ref Player.State playerState) { // Countdown countDownPanel.SetPanelActive(playerState.displayCountDown); if (playerState.displayCountDown) { countDownPanel.levelInfoCounter.Format("{0}", playerState.countDown); } // Scoreboard scoreboardPanel.SetPanelActive(!playerState.displayCountDown && (playerState.displayScoreBoard || GatedInput.GetKey(KeyCode.Tab) || m_ShowScorePanel)); // Game score panel gameScorePanel.SetPanelActive(playerState.displayGameScore); }
public void FillStates(Player player) { PlayerState.Initializer init = new PlayerState.Initializer { stateMachine = this, player = player }; mapStates = new Dictionary <Player.State, PlayerState>(); foreach (PlayerState state in states) { PlayerState newState = Object.Instantiate(state) as PlayerState; newState.Initialize(init); mapStates.Add(state.State, newState); } nextState = currentState; mapStates[currentState].OnStateEnter(); }
public Winner CheckWinner(Player.State[,] array, Player.State player) { var result = new Winner(); if (array == null) { return(result); } foreach (var direction in _directionsCheck) { result = CheckWinner(array, player, direction); if (result != null && result.Name != Player.Name.None.ToString()) { break; } } return(result); }
public ExplosionCrate(Vector2 spritePosition, string spriteSheetName, string clipExplosionName = "tntExplosion", DrawManager.Layer drawLayer = DrawManager.Layer.Playground) : base(spritePosition, spriteSheetName, drawLayer) { sprite.scale = new Vector2(1.8f, 1.8f); Animation.IsActive = false; ClipBroken = AudioManager.GetAudioClip(clipExplosionName); float ray = (float)(Math.Sqrt(Width * Width + Height * Height) / 2) - Width / 6f; Circle circleCollider = new Circle(Vector2.Zero, null, ray); RigidBody = new RigidBody(spritePosition, this, circleCollider, null, false); RigidBody.Type = (uint)PhysicsManager.ColliderType.Explosion; collisionMask = (uint)(PhysicsManager.ColliderType.Player | PhysicsManager.ColliderType.Crate | PhysicsManager.ColliderType.Pickable | PhysicsManager.ColliderType.Enemy); RigidBody.SetCollisionMask(collisionMask); objectAlreadyHitted = new List <GameObject>(); PlayerDeathAnim = Player.State.DeathBurnt; }
public bool IsPlayerAuthorised(int playerIndex) { Player.State currentState = _players[playerIndex].CurrentState; return(currentState == Player.State.AuthorisedWaitingForInfo || currentState == Player.State.AuthorisedPlaying); }
public void OnPlayerRespawn(ref Player.State playerState, ref Vector3 position, ref Quaternion rotation) { m_GameModeSystemServer.GetRandomSpawnTransform(playerState.teamIndex, ref position, ref rotation); }
public void OnPlayerJoin(ref Player.State playerState) { playerState.score = 0; m_GameModeSystemServer.AssignTeam(ref playerState); }
public void OnPlayerKilled(ref Player.State victim, ref Player.State killer) { }
public void SetState(Player.State state) { nextState = state; }
public void FrameUpdate(ref Player.State playerState) { if (!playerState.displayGoal) { goalIndicator.SetActive(false); return; } goalIndicator.SetActive(true); Vector3 goalPosition = playerState.goalPosition; var c = GameApp.CameraStack.TopCamera(); var sp = c.WorldToScreenPoint(goalPosition); sp.z = 0; sp.x = sp.x / Screen.width - 0.5f; sp.y = sp.y / Screen.height - 0.5f; float sp_mag = sp.magnitude; if (sp_mag > 1.0f) { sp /= sp_mag; } float dot = Vector3.Dot(c.transform.forward, (goalPosition - c.transform.position).normalized); if (dot < 0.25f) { float blend = Mathf.Clamp01(dot * 4.0f); float lr = Vector3.Dot(c.transform.right, (goalPosition - c.transform.position).normalized); Vector3 behind_sp = new Vector3(lr * 0.5f, -0.5f, 0); sp = Vector3.Lerp(behind_sp, sp, blend); } float arrowDirection = 180.0f; var inner = sp; inner.x = Mathf.Clamp(sp.x, -0.3f, 0.3f); inner.y = Mathf.Clamp(sp.y, -0.2f, 0.3f); if (dot < 0.0f || (sp - inner).magnitude > 0.15f) { // If outside center area of screen, show arrow pointing in direction of goal var d = sp.normalized; arrowDirection = Mathf.Atan2(-d.x, d.y) * 180.0f / Mathf.PI; sp = inner + (sp - inner).normalized * 0.15f; goalArrow.enabled = true; goalCenter.enabled = false; } else { goalCenter.enabled = true; goalArrow.enabled = false; } sp.x = (sp.x + 0.5f) * Screen.width; sp.y = (sp.y + 0.5f) * Screen.height; goalIndicator.transform.position = sp; var la = goalArrow.transform.localEulerAngles; la.z = arrowDirection; goalArrow.transform.localEulerAngles = la; goalArrow.SetRGB(Game.game.gameColors[(int)playerState.goalDefendersColor]); goalCenter.SetRGB(Game.game.gameColors[(int)playerState.goalDefendersColor]); goalProgress.fillAmount = playerState.goalCompletion; }
public void OnPlayerRespawn(ref Player.State player, ref Vector3 position, ref Quaternion rotation) { }
private void ChangePlayerState(Player.State state) { Player.Instance.CurrentState = state; }
private static Winner CheckWinner(Player.State[,] array, Player.State player, string direction) { var lineSize = (int)Math.Sqrt(array.Length); var result = new Winner(lineSize); var tmpResult = new string[lineSize, 1]; var lineCheck = new Player.State[lineSize]; if (array.Length <= 2) { return(result); } for (var j = 0; j < lineSize; j++) { switch (direction) { case "diagTopDown": case "diagDownTop": { if (direction == "diagTopDown") { lineCheck[j] = array[j, j]; tmpResult[j, 0] = $"{j}{j}"; } else if (direction == "diagDownTop") { lineCheck[j] = array[j, (lineSize - 1) - j]; tmpResult[j, 0] = $"{j}{(lineSize - 1) - j}"; } break; } case "column": case "row": { for (var i = 0; i < lineSize; i++) { if (direction == "column") { lineCheck[i] = array[i, j]; tmpResult[i, 0] = $"{i}{j}"; } else if (direction == "row") { lineCheck[i] = array[j, i]; tmpResult[j, 0] = $"{i}{j}"; } } break; } } if (!IsFound(lineCheck, player)) { continue; } result.Name = Player.DefaultPlayers()[player]; result.Result = tmpResult; break; } return(result); }
public string hitBy; // Username of the player the hit came from public ColInfo(Vector2 _vel, Player.State _state, string _username) { hitBy = _username; velocity = _vel; state = _state; }