Example #1
0
 // 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;
 }
Example #2
0
    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;
        }
Example #4
0
 // 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;
 }
Example #5
0
        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);
                }
            }
        }
Example #6
0
 public PlayerState(Player.State state_, bool cloud, bool isLock_, int tmp)
 {
     state   = state_;
     onCloud = cloud;
     isLock  = isLock_;
     temp    = tmp;
 }
Example #7
0
        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++;
     }
 }
Example #10
0
        private IEnumerator IncrementAvailableMoves(Player.State _state)
        {
            yield return(new WaitForSeconds(Constants.COOLDOWNS[_state]));

            m_availableMoves[_state]++;
            StartCoroutine(m_playerInfo.UpdateAction(_state, m_availableMoves[_state]));
        }
Example #11
0
 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();
 }
Example #12
0
        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
        }
Example #13
0
        /// <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();
 }
Example #15
0
    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);
        }
    }
Example #16
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");
     }
 }
Example #17
0
 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--;
     }
 }
Example #18
0
    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);
        }
    }
Example #19
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();
    }
Example #21
0
        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;
        }
Example #23
0
 public bool IsPlayerAuthorised(int playerIndex)
 {
     Player.State currentState = _players[playerIndex].CurrentState;
     return(currentState == Player.State.AuthorisedWaitingForInfo || currentState == Player.State.AuthorisedPlaying);
 }
Example #24
0
 public void OnPlayerRespawn(ref Player.State playerState, ref Vector3 position, ref Quaternion rotation)
 {
     m_GameModeSystemServer.GetRandomSpawnTransform(playerState.teamIndex, ref position, ref rotation);
 }
Example #25
0
 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;
 }
Example #28
0
    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)
 {
 }
Example #30
0
 private void ChangePlayerState(Player.State state)
 {
     Player.Instance.CurrentState = state;
 }
Example #31
0
        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);
        }
Example #32
0
 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;
 }