Example #1
0
    private DanceStep GenerateRandomStep()
    {
        int       rand = Random.Range(0, 4);
        DanceStep step = DanceStep.Up;

        switch (rand)
        {
        case 0:
            step = DanceStep.Up;
            break;

        case 1:
            step = DanceStep.Down;
            break;

        case 2:
            step = DanceStep.Left;
            break;

        case 3:
            step = DanceStep.Right;
            break;
        }

        return(step);
    }
Example #2
0
    private void CheckDanceStepRequired(DanceStep danceStepInsideCirlePoint)
    {
        bool isPerfect = true;

        foreach (Transform item in currentDanceStepsAcquiredParent.transform)
        {
            DanceStep danceStep = item.GetComponent <DanceStep>();

            if (!danceStep.isActivated && danceStepInsideCirlePoint.danceStepSORef != danceStep.danceStepSORef)
            {
                isPerfect    = false;
                currentCombo = 0;
            }

            if (!danceStep.isActivated && danceStepInsideCirlePoint.danceStepSORef == danceStep.danceStepSORef)
            {
                AccomplishStepDance(danceStep, danceStepInsideCirlePoint.gameObject);

                if (isPerfect)
                {
                    currentCombo++;
                    SpawnPopup("Perfect X" + currentCombo);

                    if (currentCombo >= perfectSounds.Length)
                    {
                        soundsManagerAudioSrc.PlayOneShot(perfectSounds[perfectSounds.Length - 1]);
                    }
                    else
                    {
                        soundsManagerAudioSrc.PlayOneShot(perfectSounds[currentCombo - 1]);
                    }
                    ScoreManager.Instance.AddScore(ScoreManager.HitType.PerfectHit);
                }
                else
                {
                    soundsManagerAudioSrc.PlayOneShot(greatSound);
                    SpawnPopup("Great");
                    ScoreManager.Instance.AddScore(ScoreManager.HitType.GreatHit);
                }

                levels[currentLevel].currentStepsAcquired++;

                if (LevelIsFinished())
                {
                    currentLevel++;

                    if (IsGameFinished())
                    {
                        reloadButton.SetActive(true);
                    }

                    canSpawnDanceSteps = false;
                    StartCoroutine(WaitToShowLevelDone());
                }

                return;
            }
        }
    }
Example #3
0
    //Resets dancer positions back one step
    public void UndoMove()
    {
        if (!CanUndo())
        {
            return;
        }
        DanceStep step = _backStack.Pop();

        Move(step.d, step.pos);
        step.d.ResettiTheSpaghetti(step.range);
        UI.UpdateUndoInteractable(this);
        BakeMovement(turn, false);
        CheckMoves();
    }
Example #4
0
    private void ChangeSpriteFromStepValue(SpriteRenderer renderer, DanceStep step, int type)
    {
        switch (step)
        {
        case DanceStep.Up:
            renderer.sprite = spriteUp[type];
            break;

        case DanceStep.Down:
            renderer.sprite = spriteDown[type];
            break;

        case DanceStep.Left:
            renderer.sprite = spriteLeft[type];
            break;

        case DanceStep.Right:
            renderer.sprite = spriteRight[type];
            break;
        }
    }
Example #5
0
 private void AccomplishStepDance(DanceStep danceStepAquired, GameObject danceStepInsideCircle)
 {
     danceStepAquired.isActivated = true;
     FollowAnimationToDanceStepAquired(danceStepAquired.transform, danceStepInsideCircle.transform);
 }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        //Select Dancer with mouse via ray
        if (Input.GetKey(KeyCode.Mouse0))
        {
            RaycastHit hit;
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);

            if (!_dancerSelected)                  //no dancer selected
            {
                if (Physics.Raycast(ray, out hit)) //8 is dancer layer
                {
                    //Hit dancer
                    _dancerSelected = hit.transform.GetComponent <Dancer>();
                    if (!_dancerSelected)
                    {
                        //Hit board
                        var hitpos   = hit.transform.position;
                        var boardPos = new Vector2(hitpos.x, hitpos.z);
                        _dancerSelected = GetDancer(boardPos);
                    }

                    //If valid selection
                    if (_dancerSelected && _dancerSelected.canMove)
                    {
                        _dancerSelected.Select();           //Select and paint selected tiles
                        PaintSelection(_dancerSelected);    //paint selected layer
                        _dancerStartMovePos = _dancerSelected.GetBoardPos();
                    }
                    else //cancel coz we can't move
                    {
                        _dancerSelected = null;
                    }
                }
            }
            else //Dancer is selected
            {
                //Move that booty
                if (Physics.Raycast(ray, out hit, 999, moverLayer.value))
                {
                    Vector2 hitBoardPos = new Vector2(hit.transform.position.x, hit.transform.position.z);

                    List <Vector2> poslist;
                    _validPositions.TryGetValue(_dancerSelected, out poslist);
                    Debug.Assert(_validPositions.ContainsKey(_dancerSelected));

                    if (poslist.Contains(hitBoardPos) || GameState.me.debug)
                    {
                        Move(_dancerSelected, hitBoardPos);
                    }
                }
            }
        }
        else if (_dancerSelected) //Deselect
        {
            //Add to back stack &  update its ui
            if (_dancerStartMovePos != _dancerSelected.GetBoardPos())
            {
                var step = new DanceStep();
                step.d     = _dancerSelected;
                step.pos   = _dancerStartMovePos;
                step.range = _dancerSelected.rangePoints;
                _backStack.Push(step);

                UI.UpdateUndoInteractable(this);
            }

            //Checky moves!
            CheckMoves();

            //Cleanup
            _dancerSelected.DeSelect();
            painter.ClearLayer(0);
            BakeMovement(turn, false);

            //Laterssss
            _dancerSelected = null;
        }

        //Round timer
        if (GameActive && GameState.me.State == eGameState.GAME)
        {
            roundCountdown     -= Time.deltaTime;
            RoundTimerText.text = roundCountdown.ToString("00");
            if (roundCountdown < 0)
            {
                EndTurn(true);
            }
        }
    }
Example #7
0
        public static void AddActionToGambit(Gambit gambit, GambitActionTypes selectedValue)
        {
            IGambitAction newAction;

            switch (selectedValue)
            {
            case GambitActionTypes.NoAction:
                newAction = new NullAction();
                break;

            case GambitActionTypes.CastSpellOnSelf:
                newAction = new CastSpellOnSelfAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnAlly:
                newAction = new CastSpellOnAllyAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnEnemy:
                newAction = new CastSpellOnEnemyAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnFriendlyNpc:
                newAction = new CastSpellOnFriendlyNpcAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.SleepForMilliseconds:
                newAction = new SleepForTimeAction {
                    DurationInMilliseconds = 1000
                };
                break;

            case GambitActionTypes.ToastMessage:
                newAction = new ToastMessageAction {
                    displaySeconds = 2, message = "The Toast Message"
                };
                break;

            case GambitActionTypes.UseItemOnSelf:
                newAction = new UseItemOnSelfAction()
                {
                    ItemName = "The Item's Name", AnyQuality = true
                };
                break;

            case GambitActionTypes.CastSpellOnCurrentTarget:
                newAction = new CastSpellOnCurrentTargetAction()
                {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastFillerOnCurrentTarget:
                newAction = new CastFillerOnCurrentTargetAction()
                {
                    SpellName = "The Filler's SpellName", ProcName = "The Proc's SpellName"
                };
                break;

            case GambitActionTypes.PetCast:
                newAction = new PetCastAction()
                {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.DanceFinish:
                newAction = new DanceFinish();
                break;

            case GambitActionTypes.DanceStep:
                newAction = new DanceStep();
                break;

            default:
                return;
            }

            gambit.ActionType = selectedValue;
            gambit.Action     = newAction;
        }
Example #8
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jsonObject = JObject.Load(reader);

            if (Enum.TryParse <GambitActionTypes>(jsonObject["GambitActionType"].Value <string>(), out var parsedEnum))
            {
                GambitAction action;
                switch (parsedEnum)
                {
                case GambitActionTypes.CastSpellOnSelf:
                    action = new CastSpellOnSelfAction();
                    break;

                case GambitActionTypes.CastSpellOnCurrentTarget:
                    action = new CastSpellOnCurrentTargetAction();
                    break;

                case GambitActionTypes.CastFillerOnCurrentTarget:
                    action = new CastFillerOnCurrentTargetAction();
                    break;

                case GambitActionTypes.CastSpellOnAlly:
                    action = new CastSpellOnAllyAction();
                    break;

                case GambitActionTypes.CastSpellOnEnemy:
                    action = new CastSpellOnEnemyAction();
                    break;

                case GambitActionTypes.CastSpellOnFriendlyNpc:
                    action = new CastSpellOnFriendlyNpcAction();
                    break;

                case GambitActionTypes.SleepForMilliseconds:
                    action = new SleepForTimeAction();
                    break;

                case GambitActionTypes.NoAction:
                    action = new NullAction();
                    break;

                case GambitActionTypes.ToastMessage:
                    action = new ToastMessageAction();
                    break;

                case GambitActionTypes.UseItemOnSelf:
                    action = new UseItemOnSelfAction();
                    break;

                case GambitActionTypes.PetCast:
                    action = new PetCastAction();
                    break;

                case GambitActionTypes.DanceFinish:
                    action = new DanceFinish();
                    break;

                case GambitActionTypes.DanceStep:
                    action = new DanceStep();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                serializer.Populate(jsonObject.CreateReader(), action);
                return(action);
            }
            throw new InvalidCastException();
        }