Beispiel #1
0
    public IEnumerator StartAI()
    {
        var jumpCell     = this.grid.ToClosestEdgeVector(this.child.Cell) * 2;
        var jumpOrigin2d = this.grid.GetCellPosition(jumpCell);
        var jumpOrigin3d = new Vector3(jumpOrigin2d.x, jumpOrigin2d.y, this.transform.position.z);

        this.child.TurnTo(jumpOrigin2d.x >= 0f ? CharMovement.Direction.LEFT : CharMovement.Direction.RIGHT);
        var jump = new JumpAnimation(this.child, from: jumpOrigin3d, to: Vector2.zero).Start();

        yield return(new WaitUntil(() => jump.HasFinished));

        while (true)
        {
            for (var i = 0; i < 3; i++)
            {
                var blocked   = this.grid.BlockedDirections(this.child.Cell);
                var direction = CharMovement.RandomDirection(except: blocked);
                var steps     = this.child.Steps;
                this.child.Move(direction);
                yield return(new WaitWhile(() => steps == this.child.Steps && !this.child.MovementBlocked));
            }
            this.child.Stop();

            for (var i = 0; i < 3; i++)
            {
                yield return(new WaitForSeconds(1f));

                this.child.TurnTo(CharMovement.RandomDirection(except: child.HeadedDirection));
            }
        }
    }
Beispiel #2
0
    private IEnumerator StartIA()
    {
        var jumpCell     = this.grid.ToClosestEdgeVector(this.hunterMovement.Cell) * 2;
        var jumpOrigin2d = this.grid.GetCellPosition(jumpCell);
        var jumpOrigin3d = new Vector3(jumpOrigin2d.x, jumpOrigin2d.y, this.transform.position.z);

        this.hunterMovement.TurnTo(jumpOrigin2d.x >= 0f ? CharMovement.Direction.LEFT : CharMovement.Direction.RIGHT);
        var jump = new JumpAnimation(this.hunterSprite, from: jumpOrigin3d, to: Vector2.zero).Start();

        yield return(new WaitUntil(() => jump.HasFinished));

        while (true)
        {
            var steps = this.hunterMovement.Steps;
            switch (state)
            {
            case State.CHASING_WITCH:
                StepFollowing(witchScent);
                yield return(new WaitWhile(() => steps == this.hunterMovement.Steps && !this.hunterMovement.MovementBlocked));

                break;

            case State.CHASING_CAULDRON:
                StepFollowing(cauldronScent);
                yield return(new WaitWhile(() => steps == this.hunterMovement.Steps && !this.hunterMovement.MovementBlocked));

                break;

            case State.SEARCHING_RANDOMLY:
                StepRandomly();
                yield return(new WaitWhile(() => steps == this.hunterMovement.Steps && !this.hunterMovement.MovementBlocked));

                break;

            case State.SHOOTING:
                this.hunterMovement.Stop();
                var anim = this.bang.Alert();
                this.hunterMovement.TurnTo(this.witchShotDirection);
                yield return(new WaitForSeconds(1f));

                yield return(new WaitUntil(() => anim.HasFinished));

                this.hunter.Shoot();
                this.state = State.CHASING_CAULDRON;
                yield return(new WaitForSeconds(1f));

                break;
            }
            ChangeState();
        }
    }
    override protected void Start()
    {
        gameOverCount = 0.0f;
        CoinGetRate   = 1f;
        scoreManager  = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();
        GameObject playFabManager = GameObject.Find("PlayFabManager");

        waitConnect = playFabManager.GetComponent <PlayFabWaitConnect>();
        playerJump  = Player.GetComponent <JumpAnimation>();

        startUI   = StartUIObject.GetComponent <StartUI>();
        restartUI = ReStartUIObject.GetComponent <StartUI>();

        adsButton = GameObject.Find("AdsButton").GetComponent <Button>();

        base.Start();

        state     = STATE.PREPRATION;
        fadeState = FADE_STATE.BLACK;
    }
        private static AnimationDefinition GetAnimationDefinition(string animationName)
        {
            AnimationDefinition animationDefinition = null;

            if (animationName != null)
            {
                switch (animationName.ToLower())
                {
                case "flash": animationDefinition = new FlashAnimation(); break;

                case "bounce": animationDefinition = new BounceAnimation(); break;

                case "shake": animationDefinition = new ShakeAnimation(); break;

                case "tada": animationDefinition = new TadaAnimation(); break;

                case "swing": animationDefinition = new SwingAnimation(); break;

                case "wobble": animationDefinition = new WobbleAnimation(); break;

                case "pulse": animationDefinition = new PulseAnimation(); break;

                case "breathing": animationDefinition = new BreathingAnimation(); break;

                case "jump": animationDefinition = new JumpAnimation(); break;

                case "flip": animationDefinition = new FlipAnimation(); break;

                case "flipinx": animationDefinition = new FlipInXAnimation(); break;

                case "flipoutx": animationDefinition = new FlipOutXAnimation(); break;

                case "flipiny": animationDefinition = new FlipInYAnimation(); break;

                case "flipouty": animationDefinition = new FlipOutYAnimation(); break;

                case "fadein": animationDefinition = new FadeInAnimation(); break;

                case "fadeout": animationDefinition = new FadeOutAnimation(); break;

                case "fadeinleft": animationDefinition = new FadeInLeftAnimation(); break;

                case "fadeinright": animationDefinition = new FadeInRightAnimation(); break;

                case "fadeinup": animationDefinition = new FadeInUpAnimation(); break;

                case "fadeindown": animationDefinition = new FadeInDownAnimation(); break;

                case "fadeoutleft": animationDefinition = new FadeOutLeftAnimation(); break;

                case "fadeoutright": animationDefinition = new FadeOutRightAnimation(); break;

                case "fadeoutup": animationDefinition = new FadeOutUpAnimation(); break;

                case "fadeoutdown": animationDefinition = new FadeOutDownAnimation(); break;

                case "bouncein": animationDefinition = new BounceInAnimation(); break;

                case "bounceout": animationDefinition = new BounceOutAnimation(); break;

                case "bounceinleft": animationDefinition = new BounceInLeftAnimation(); break;

                case "bounceinright": animationDefinition = new BounceInRightAnimation(); break;

                case "bounceinup": animationDefinition = new BounceInUpAnimation(); break;

                case "bounceindown": animationDefinition = new BounceInDownAnimation(); break;

                case "bounceoutleft": animationDefinition = new BounceOutLeftAnimation(); break;

                case "bounceoutright": animationDefinition = new BounceOutRightAnimation(); break;

                case "bounceoutup": animationDefinition = new BounceOutUpAnimation(); break;

                case "bounceoutdown": animationDefinition = new BounceOutDownAnimation(); break;

                case "scalein": animationDefinition = new ScaleInAnimation(); break;

                case "scaleout": animationDefinition = new ScaleOutAnimation(); break;

                case "lightspeedinleft": animationDefinition = new LightSpeedInLeftAnimation(); break;

                case "lightspeedinright": animationDefinition = new LightSpeedInRightAnimation(); break;

                case "lightspeedoutleft": animationDefinition = new LightSpeedOutLeftAnimation(); break;

                case "lightspeedoutright": animationDefinition = new LightSpeedOutRightAnimation(); break;

                case "hinge": animationDefinition = new HingeAnimation(); break;

                case "reset": animationDefinition = new ResetAnimation(); break;
                }
            }
            return(animationDefinition);
        }