Пример #1
0
 public void NotifySequenceObservers(SequenceActions sequenceAction, StoredPlayerMove move)
 {
     foreach (ISequenceObserver observer in _sequenceObservers)
     {
         observer.OnSequenceChange(sequenceAction, move);
     }
 }
Пример #2
0
        public void OnSequenceChange(SequenceActions sequenceAction, StoredPlayerMove move)
        {
            //Type | Time | Player | Direction
            switch (sequenceAction)
            {
            case SequenceActions.NewMoveAdded:
                //Type | Time | Player | Direction
                _textWriter.WriteLine("{0},{1},{2},{3}", sequenceAction, GetTimeReadable(), move.PlayerTags, move.Direction);
                break;

            case SequenceActions.MoveRemoved:
                //Type | Time | Player | Direction
                _textWriter.WriteLine("{0},{1},{2},{3}", sequenceAction, GetTimeReadable(), move.PlayerTags, move.Direction);
                break;

            case SequenceActions.SequenceStarted:
                //Type | Time
                _textWriter.WriteLine("{0},{1}", sequenceAction, GetTimeReadable());
                break;

            case SequenceActions.SequenceEnded:
                _textWriter.WriteLine("{0},{1}", sequenceAction, GetTimeReadable());
                break;

            case SequenceActions.MovePerformed:
                _textWriter.WriteLine("{0},{1},{2},{3}", sequenceAction, GetTimeReadable(), move.PlayerTags, move.Direction);
                _nrOfMoves++;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(sequenceAction), sequenceAction, null);
            }
        }
Пример #3
0
        /// <summary>
        /// Adds a move to the common sequence
        /// </summary>
        /// <param name="p"></param>
        /// <param name="d"></param>
        /// <param name="index"></param>
        public virtual void AddMoveToSequence(PlayerTags p, Direction d, int moveId, int index)
        {
            PlayerController playerController = GetPlayerController(p);

            if (playerController == null)
            {
                throw new ArgumentException(p + " is not active");
            }

            if (playerController.GetIndexForDirection(d) == -1)
            {
                throw new InvalidOperationException($"{playerPrefab} does not posses the {d} move");
            }

            if (d == Direction.Blank)
            {
                throw new ArgumentException("Can't add blank moves");
            }

            StoredPlayerMove playerMove = new StoredPlayerMove(p, d, index, moveId);

            _sequenceMoves.Add(playerMove);

            playerController.RemoveMove(index);

            playerController.NotifyInventoryObservers();
            NotifySequenceObservers(SequenceActions.NewMoveAdded, playerMove);
        }
Пример #4
0
        private void AddMove(StoredPlayerMove move)
        {
            //Image img = transform.GetChild(_nrOfMovesInSequence).GetComponent<Image>();
            //img.color = ColorPalette.current.GetPlayerColor(move.PlayerTags);

            Image img = GetElement(_nrOfMovesInSequence).GetComponent <SequenceArrowController>().image;

            img.color = ColorPalette.current.GetPlayerColor(move.PlayerTags);

            GetElement(_nrOfMovesInSequence).GetComponent <SequenceArrowController>().index = _nrOfMovesInSequence;
            GetElement(_nrOfMovesInSequence).GetComponent <SequenceArrowController>().move  = move;


            GetElement(_nrOfMovesInSequence).GetComponent <Button>().interactable = GUIEvents.current.GetCurrentPlayer() == move.PlayerTags;
            GetElement(_nrOfMovesInSequence).GetComponent <SequenceArrowController>().SetMouseHover(GUIEvents.current.GetCurrentPlayer() == move.PlayerTags);
            GetElement(_nrOfMovesInSequence).GetComponent <SequenceArrowController>().SetCancelButtonActive(GUIEvents.current.GetCurrentPlayer() == move.PlayerTags);


            LeanTween.color(img.rectTransform, ColorPalette.current.GetPlayerColor(move.PlayerTags), 0.3f).setEase(LeanTweenType.easeOutSine);

            int     rotationZ = GlobalMethods.GetDirectionRotation(move.Direction);
            Vector3 rotation  = new Vector3(0, 0, rotationZ);

            Vector3 reverseRotation;

            if (rotationZ == 90 || rotationZ == -90)
            {
                reverseRotation = new Vector3(0, 0, rotationZ * -1);
            }

            if (rotationZ == 180)
            {
                reverseRotation = new Vector3(0, 0, 0);
            }
            else
            {
                reverseRotation = new Vector3(0, 0, 180);
            }


            img.gameObject.transform.rotation = Quaternion.Euler(reverseRotation);

            LeanTween.rotateLocal(img.gameObject, rotation, 0.3f).setEase(LeanTweenType.easeOutSine);
            _nrOfMovesInSequence++;
        }
Пример #5
0
        public void OnSequenceChange(SequenceActions sequenceAction, StoredPlayerMove move)
        {
            switch (sequenceAction)
            {
            case SequenceActions.NewMoveAdded:
                AddMove(move);
                break;

            case SequenceActions.MoveRemoved:
                RemoveMove(move);
                break;

            case SequenceActions.SequenceStarted:
                float delay = GameHandler.Current.delayBetweenMoves;
                StartCoroutine(ClearSequence(delay));
                break;
            }
        }
Пример #6
0
    public void OnSequenceChange(SequenceActions sequenceAction, StoredPlayerMove move)
    {
        switch (sequenceAction)
        {
        case SequenceActions.NewMoveAdded:
            break;

        case SequenceActions.MoveRemoved:
            break;

        case SequenceActions.SequenceStarted:
            _oldString = "";
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(sequenceAction), sequenceAction, null);
        }
    }
Пример #7
0
        /// <summary>
        /// Removes a move from the common sequence
        /// </summary>
        /// <param name="move"></param>
        public virtual void RemoveMoveFromSequence(StoredPlayerMove move)
        {
            StoredPlayerMove currentMove;

            try
            {
                currentMove = _sequenceMoves.First(item => item.Id == move.Id);
            }
            catch (Exception e)
            {
                Debug.Log($"RemoveFromSequence Error: {e}");
                return;
            }

            _sequenceMoves.Remove(currentMove);

            GetPlayerController(move.PlayerTags).AddMove(move.Direction, move.moveIndex);
            NotifySequenceObservers(SequenceActions.MoveRemoved, currentMove);
        }
Пример #8
0
        private void RemoveMove(StoredPlayerMove move)
        {
            List <StoredPlayerMove> moves = GameHandler.Current.GetSequence();
            int i = 0;

            foreach (StoredPlayerMove playerMove in moves)
            {
                SequenceArrowController arrowController = GetElement(i).GetComponent <SequenceArrowController>();
                Transform element = GetElement(i);
                i++;
                if (arrowController.move.Id == playerMove.Id)
                {
                    continue;
                }

                arrowController.move = playerMove;

                Image img = arrowController.image;

                element.GetComponent <Button>().interactable = GUIEvents.current.GetCurrentPlayer() == playerMove.PlayerTags;
                element.GetComponent <SequenceArrowController>().SetCancelButtonActive(GUIEvents.current.GetCurrentPlayer() == playerMove.PlayerTags);
                element.GetComponent <SequenceArrowController>().SetMouseHover(GUIEvents.current.GetCurrentPlayer() == playerMove.PlayerTags);

                //Rotation stuff
                LeanTween.color(img.rectTransform, ColorPalette.current.GetPlayerColor(playerMove.PlayerTags), 0.3f).setEase(LeanTweenType.easeOutSine);


                Vector3 rotation = new Vector3(0, 0, GlobalMethods.GetDirectionRotation(playerMove.Direction));
                LeanTween.rotateLocal(img.gameObject, rotation, 0.3f).setEase(LeanTweenType.easeOutSine);
            }

            for (int j = i; j < _nrOfMovesInSequence; j++)
            {
                Image img = GetElement(i).GetComponent <SequenceArrowController>().image;
                GetElement(i).GetComponent <SequenceArrowController>().SetCancelButtonActive(false);
                GetElement(i).GetComponent <Button>().interactable = false;

                LeanTween.color(img.rectTransform, idleColor, 0.3f);
            }

            _nrOfMovesInSequence--;
        }
Пример #9
0
 public void NotifySequenceObservers(SequenceActions sequenceAction, StoredPlayerMove move)
 {
     throw new System.NotImplementedException();
 }
Пример #10
0
        public void RPC_RemoveMoveFromSequence(PlayerTags pTag, Direction d, int index, int id)
        {
            StoredPlayerMove storedPMove = new StoredPlayerMove(pTag, d, index, id);

            gameHandler.RemoveMoveFromSequence(storedPMove);
        }
Пример #11
0
 /// <summary>
 /// RemoveMoveFromSequence()
 /// </summary>
 /// <param name="move"></param>
 public void RemoveMoveFromSequence(StoredPlayerMove move)
 {
     photonView.RPC("RPC_RemoveMoveFromSequence", RpcTarget.Others, move.PlayerTags, move.Direction, move.moveIndex, move.Id);
 }
Пример #12
0
 public void OnSequenceChange(SequenceActions sequenceAction, StoredPlayerMove move)
 {
     StartCoroutine(PopulateMap(0.5f));
 }
Пример #13
0
 public override void RemoveMoveFromSequence(StoredPlayerMove move)
 {
     MyNetworkedAgent.RemoveMoveFromSequence(move);
     localGameHandler.RemoveMoveFromSequence(move);
 }