Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        romanceMusic.Play();
        spyMusic.Play();

        spyMusic.volume     = .75f;
        romanceMusic.volume = .75f;

        rhythmUI.StartSong(replayMode);

        nextDirection = GameDirection.none;
        cluck         = false;

        checks = 0;

        replayFrameNumber = 0;
        if (!replayMode)
        {
            replayQueue = new List <replayFrame>();
        }

        GameObject.Find("ReplayButton").GetComponent <Image> ().enabled    = false;
        GameObject.Find("ReplayButtonText").GetComponent <Text> ().enabled = false;

//		SwitchToDatingSimMode ();
//		checks++;
    }
Exemplo n.º 2
0
        public Tux(int top, int left)
            : base()
        {
            Top = top;
            Left = left;

            imgNormal = new AnimateImage(Files.tux_normal, 200, GameDirection.Left, GameDirection.Right);
            imgSmall = new AnimateImage(Files.tux_small, 200, GameDirection.Left, GameDirection.Right);

            Width = imgNormal.CurImage(direction).Width;
            Height = imgNormal.CurImage(direction).Height;

            curimg = imgNormal;
            direction = GameDirection.Right;

            firePressed = false;
            mode = MainGameObjectMode.Normal;

            immortializeEnd = DateTime.Now;
            immortialize = false;

            GamePhysics.JumpData jumping = new GamePhysics.JumpData();
            jumping.direction = GameDirection.None;
            jumping.distance = 0;
            this.jumping = jumping;

            wantNext = new Queue<WantNext>();
        }
Exemplo n.º 3
0
 public GameInstruction(InstructionType type, GameObject go, GameDirection direction, float value)
 {
     this.type = type;
     this.go = go;
     this.direction = direction;
     this.value = value;
 }
Exemplo n.º 4
0
    public static GameDirection RandomSingle(this GameDirection input)
    {
        List <GameDirection> options = new List <GameDirection>();

        if (input.Test(GameDirection.North))
        {
            options.Add(GameDirection.North);
        }
        if (input.Test(GameDirection.East))
        {
            options.Add(GameDirection.East);
        }
        if (input.Test(GameDirection.South))
        {
            options.Add(GameDirection.South);
        }
        if (input.Test(GameDirection.West))
        {
            options.Add(GameDirection.West);
        }
        if (options.Count == 0)
        {
            return(GameDirectionHelper.Nil);
        }
        return(options[Random.Range(0, options.Count)]);
    }
Exemplo n.º 5
0
    public static GameDirection RotateCCW(GameDirection input)
    {
        if (input == Nil)
        {
            return(Nil);
        }
        if (input == All)
        {
            return(All);
        }

        GameDirection output = Nil;

        if (input.Test(GameDirection.North))
        {
            output |= GameDirection.West;
        }
        if (input.Test(GameDirection.East))
        {
            output |= GameDirection.South;
        }
        if (input.Test(GameDirection.South))
        {
            output |= GameDirection.East;
        }
        if (input.Test(GameDirection.West))
        {
            output |= GameDirection.North;
        }
        return(output);
    }
Exemplo n.º 6
0
    /**
     * Return in degrees
     */
    public static float AngleFrom(GameDirection from, GameDirection to)
    {
        switch (from)
        {
        case GameDirection.North:
            switch (to)
            {
            case GameDirection.North: return(0f);

            case GameDirection.East: return(90f);

            case GameDirection.South: return(180f);

            case GameDirection.West: return(270f);
            }
            break;

        case GameDirection.East:
            switch (to)
            {
            case GameDirection.North: return(270f);

            case GameDirection.East: return(0f);

            case GameDirection.South: return(90f);

            case GameDirection.West: return(180f);
            }
            break;

        case GameDirection.South:
            switch (to)
            {
            case GameDirection.North: return(180f);

            case GameDirection.East: return(270f);

            case GameDirection.South: return(0f);

            case GameDirection.West: return(90f);
            }
            break;

        case GameDirection.West:
            switch (to)
            {
            case GameDirection.North: return(90f);

            case GameDirection.East: return(180f);

            case GameDirection.South: return(270f);

            case GameDirection.West: return(0f);
            }
            break;
        }

        return(0f);
    }
Exemplo n.º 7
0
        public override void Check(out Dictionary<string, float> newpos)
        {
            base.Check(out newpos);
            float newtop = newpos["top"];
            float newleft = newpos["left"];

            switch (direction)
            {
                case GameDirection.Right: newleft += Globals.ImmortializeStarMove.X * GameAI.FrameFactor; break;
                case GameDirection.Left: newleft -= Globals.ImmortializeStarMove.X * GameAI.FrameFactor; break;
            }
            switch (flyDirection)
            {
                case GameDirection.Top: newtop -= Globals.ImmortializeStarMove.Y * GameAI.FrameFactor; break;
                case GameDirection.Bottom: newtop += Globals.ImmortializeStarMove.Y * GameAI.FrameFactor; break;
            }

            if (flyDirection == GameDirection.Top)
                distance += Globals.ImmortializeStarMove.Y * GameAI.FrameFactor;

            if (distance > 200)
            {
                flyDirection = GameDirection.Bottom;
                distance = 0;
            }

            // check if direction is ok
            GamePhysics.CrashDetection(this, World.StickyElements, World.MovingElements, getEvent, ref newtop, ref newleft);
            Enemy crashedInEnemy = GamePhysics.CrashEnemy(this, World.Enemies, getEvent, ref newtop, ref newleft);
            if (GamePhysics.SimpleCrashDetections(this, World.StickyElements, World.MovingElements, true, newtop, newleft))
            {
                World.MovingElements.Remove(this);
                return;
            }

            if (newtop != 0)
                Top += newtop;
            else
                flyDirection = GameDirection.Top;

            if (newleft != 0)
                Left += newleft;
            else
            {
                switch (direction)
                {
                    case GameDirection.Right: direction = GameDirection.Left; break;
                    case GameDirection.Left: direction = GameDirection.Right; break;
                }
            }

            runs++;

            // away?
            if (runs >= 150 || Top > World.Settings.LevelHeight)
            {
                World.MovingElements.Remove(this);
            }
        }
Exemplo n.º 8
0
 public Fire(GameDirection direction, float top, float left)
     : base(GetDraw.Image(Files.fire), top, left)
 {
     this.direction = direction;
     flyDirection = GameDirection.Bottom;
     flyTopCount = 0;
     runs = 0;
 }
Exemplo n.º 9
0
 public Mushroom(MushroomType mtype, GameDirection direction, float top, float left)
     : base(Mushroom.GetMushroomImage(mtype),
     top - Mushroom.GetMushroomImage(mtype).Height,
     left)
 {
     this.mtype = mtype;
     distance = 0;
     this.direction = direction;
 }
Exemplo n.º 10
0
 public ImmortializeStar(GameDirection direction, float top, float left)
     : base(GetDraw.Image(Files.star),
     top - GetDraw.Image(Files.star).Height,
     left)
 {
     this.direction = direction;
     flyDirection = GameDirection.Top;
     distance = 0;
     runs = 0;
 }
Exemplo n.º 11
0
    public static int CountContains(this GameDirection input, params GameDirection[] tests)
    {
        int count = 0;

        foreach (GameDirection test in tests)
        {
            if (input.Test(test))
            {
                count++;
            }
        }
        return(count);
    }
Exemplo n.º 12
0
        public void ChangeGameDirection()
        {
            this._direction = this._direction == GameDirection.DIRECTION_FORWARDS ? GameDirection.DIRECTION_BACKWARDS : GameDirection.DIRECTION_FORWARDS;


            //if (this.Direction == GameDirection.DIRECTION_FORWARDS)
            //{
            //    this.Direction = GameDirection.DIRECTION_BACKWARDS;
            //}
            //else
            //{
            //    this.Direction = GameDirection.DIRECTION_FORWARDS;
            //}
        }
Exemplo n.º 13
0
Arquivo: Player.cs Projeto: atil/ld48
        public void HandleExclamation(int oxygen, GameDirection direction)
        {
            const int oxygenLimit         = 3;
            bool      isExclamationActive = oxygen <= oxygenLimit;

            Exclamation.SetActive(isExclamationActive);
            Exclamation.transform.SetParent(direction == GameDirection.Down ? ExclamationParentDown : ExclamationParentUp, false);

            // if (isExclamationActive
            //     && (isExclamationActive != _isExclamationActivePrev))
            // {
            //     Sfx.Instance.Play("OxygenWarning");
            // }

            _isExclamationActivePrev = isExclamationActive;
        }
Exemplo n.º 14
0
    float GetSpeedUpValue(Vector2 normal, string colTag, GameDirection direction)
    {
        float ret = 0;

        //if (colTag == "Paddle" && normal.y == 1)
        //{
        switch (direction)
        {
        case GameDirection.GD_HORIZONTAL:
            ret += speedUp.x * normal.x;
            break;

        case GameDirection.GD_VERTICAL:
            ret += speedUp.y * normal.y;
            break;
        }
        //}
        return(ret);
    }
Exemplo n.º 15
0
        private IEnumerator SwimUpCoroutine()
        {
            _isMoving = true;

            Sfx.Instance.Play("SwimUpRotate");

            const float moveDuration     = 1.5f;
            int         amountOfMovement = Mathf.Abs((_tiles.Count - 1) - PlayerRowIndex);

            Direction = GameDirection.Up;

            CoroutineStarter.Run(Player.PlayMoveAnim(moveDuration, Direction));

            const float spaceBetweenTiles = 1.5f;
            Vector3     scrollAmount      = (Direction == GameDirection.Up ? Vector3.up : Vector3.down) * spaceBetweenTiles * amountOfMovement;
            Vector3     cameraSrc         = CameraTransform.position;
            Vector3     cameraTarget      = cameraSrc + scrollAmount;

            Player.Exclamation.transform.SetParent(Player.ExclamationParentUp, false);

            Curve.Tween(MoveCurve,
                        moveDuration,
                        t =>
            {
                CameraTransform.position = Vector3.Lerp(cameraSrc, cameraTarget, t);
            },
                        () =>
            {
                CameraTransform.position = cameraTarget;
            });


            EndTileRoot.SetActive(true);
            EndTileRoot.GetComponent <Tile>().Index = (-1, 2);

            OnReturnStage = true;

            yield return(new WaitForSeconds(moveDuration));

            _isMoving = false;
        }
Exemplo n.º 16
0
    public static GridPos Adjacent(this GridPos me, GameDirection dir)
    {
        if (dir == GameDirection.North)
        {
            return(new GridPos(me.x, me.z + 1));
        }
        if (dir == GameDirection.East)
        {
            return(new GridPos(me.x + 1, me.z));
        }
        if (dir == GameDirection.South)
        {
            return(new GridPos(me.x, me.z - 1));
        }
        if (dir == GameDirection.West)
        {
            return(new GridPos(me.x - 1, me.z));
        }

        return(GridPos.Invalid);
    }
Exemplo n.º 17
0
        public void Init(GameObject head, int segments = 1, GameDirection direction = GameDirection.Right)
        {
            Direction = direction;

            Segments.Clear();
            Segments.Add(head);

            GameObject pseg = head;

            for (int i = 0; i < segments; i++)
            {
                float x, y;

                switch (direction)
                {
                case GameDirection.Up:
                    x = pseg.X;
                    y = pseg.Y + pseg.Height;
                    break;

                case GameDirection.Down:
                    x = pseg.X;
                    y = pseg.Y - pseg.Height;
                    break;

                case GameDirection.Left:
                    x = pseg.X + pseg.Width;
                    y = pseg.Y;
                    break;

                default:
                    x = pseg.X - pseg.Width;
                    y = pseg.Y;
                    break;
                }
                GameObject nseg = new GameObject(x, y, pseg.Width, pseg.Height);
                Segments.Add(nseg);
                pseg = nseg;
            }
        }
Exemplo n.º 18
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (who == GameElement.MGO)
            {
                switch (World.MGO.Mode)
                {
                    case MainGameObjectMode.Small:
                    case MainGameObjectMode.Normal:
                        geventhandler(GameEvent.gotFireFlower, new Dictionary<GameEventArg, object>());
                        break;
                    case MainGameObjectMode.NormalFire:
                        Dictionary<GameEventArg, object> pointsArgs = new Dictionary<GameEventArg,object>();
                        pointsArgs[GameEventArg.points] = 10;
                        geventhandler(GameEvent.gotPoints, pointsArgs);
                        break;
                }

                World.StickyElements.Remove(this);
            }
        }
Exemplo n.º 19
0
    public GameDirection DirectionTo(GridPos adj)
    {
        GameDirection result = GameDirectionHelper.Nil;

        if (adj.z > z)
        {
            result |= GameDirection.North;
        }
        if (adj.x > x)
        {
            result |= GameDirection.East;
        }
        if (adj.z < z)
        {
            result |= GameDirection.South;
        }
        if (adj.x < x)
        {
            result |= GameDirection.West;
        }
        return(result);
    }
Exemplo n.º 20
0
    public static int Count(this GameDirection input)
    {
        int total = 0;

        if (input.Test(GameDirection.North))
        {
            total++;
        }
        if (input.Test(GameDirection.East))
        {
            total++;
        }
        if (input.Test(GameDirection.South))
        {
            total++;
        }
        if (input.Test(GameDirection.West))
        {
            total++;
        }
        return(total);
    }
Exemplo n.º 21
0
Arquivo: Player.cs Projeto: atil/ld48
        public IEnumerator PlayMoveAnim(float duration, GameDirection direction)
        {
            Vector3 scale = Visual.transform.localScale;

            if (direction == GameDirection.Down)
            {
                scale.y = -Mathf.Abs(scale.y);
            }
            else
            {
                scale.y = Mathf.Abs(scale.y);
            }

            Visual.transform.localScale = scale;
            if (_idleCoroutine != null)
            {
                CoroutineStarter.Stop(_idleCoroutine);
            }

            yield return(CoroutineStarter.Run(PlayFxCoroutine(MoveSprites, duration, 9)));

            PlayIdleAnim(direction);
        }
Exemplo n.º 22
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (color == BrickColor.Ice && who == GameElement.MGO && direction == GameDirection.Top)
            {
                switch (World.MGO.Direction)
                {
                    case GameDirection.Left:
                        for (int i = 0; i < 2; i++)
                        {
                            fillMgoMoveQueue(MoveType.goLeft);
                        }
                        break;
                    case GameDirection.Right:
                        for (int i = 0; i < 2; i++)
                        {
                            fillMgoMoveQueue(MoveType.goRight);
                        }
                        break;
                }
            }
        }
Exemplo n.º 23
0
Arquivo: Player.cs Projeto: atil/ld48
        public void PlayIdleAnim(GameDirection direction)
        {
            Vector3 scale = Visual.transform.localScale;

            if (direction == GameDirection.Down)
            {
                scale.y = -Mathf.Abs(scale.y);
            }
            else
            {
                scale.y = Mathf.Abs(scale.y);
            }

            Visual.transform.localScale = scale;


            if (_idleCoroutine != null)
            {
                CoroutineStarter.Stop(_idleCoroutine);
            }

            _idleCoroutine = CoroutineStarter.Run(PlayFxCoroutine(IdleSprites, 999, 4));
        }
Exemplo n.º 24
0
Arquivo: Player.cs Projeto: atil/ld48
        public IEnumerator PlayDeadAnim(float duration, GameDirection direction)
        {
            Vector3 scale = Visual.transform.localScale;

            if (direction == GameDirection.Down)
            {
                scale.y = -Mathf.Abs(scale.y);
            }
            else
            {
                scale.y = Mathf.Abs(scale.y);
            }

            Visual.transform.localScale = scale;
            if (_idleCoroutine != null)
            {
                CoroutineStarter.Stop(_idleCoroutine);
            }

            Visual.sprite = DeadSprite;

            yield return(CoroutineStarter.Run(PlayFlipCoroutine(duration)));
        }
Exemplo n.º 25
0
 public static bool Test(this GameDirection input, GameDirection test)
 {
     return((input & test) == test);
 }
Exemplo n.º 26
0
        public override void Check(out Dictionary<string, float> newpos)
        {
            base.Check(out newpos);
            float newtop = newpos["top"];
            float newleft = newpos["left"];

            switch (direction)
            {
                case GameDirection.Right: newleft += Globals.FireMove.X * GameAI.FrameFactor; break;
                case GameDirection.Left: newleft -= Globals.FireMove.X * GameAI.FrameFactor; break;
            }

            if (runs >= 50)
            {
                switch(flyDirection)
                {
                    case GameDirection.Bottom: newtop += Globals.FireMove.Y * GameAI.FrameFactor; break;
                    case GameDirection.Top: newtop -= Globals.FireMove.Y * GameAI.FrameFactor; break;
                }
            }
            runs++;

            if (flyDirection == GameDirection.Top)
                flyTopCount++;

            if (flyTopCount > 10)
            {
                flyDirection = GameDirection.Bottom;
                flyTopCount = 0;
            }

            // check if direction is ok
            GamePhysics.CrashDetection(this, World.StickyElements, World.MovingElements, getEvent, ref newtop, ref newleft);
            Enemy crashedInEnemy = GamePhysics.CrashEnemy(this, World.Enemies, getEvent, ref newtop, ref newleft);
            if (GamePhysics.SimpleCrashDetections(this, World.StickyElements, World.MovingElements, true, newtop, newleft))
            {
                World.MovingElements.Remove(this);
                return;
            }

            if (crashedInEnemy != null) // crashed in some enemy
            {
                if (crashedInEnemy.fireCanDelete) // fire can delete it?
                {
                    crashedInEnemy.Remove();
                    World.MovingElements.Remove(this);
                }
                else // crashed in enemy and fire can't delete it --> remove fire
                    World.MovingElements.Remove(this);
                return;
            }

            if (newtop != 0)
                Top += newtop;
            else if (runs >= 52) // 50 -> start moving, +1 -> nothing moved, so use +2!
                flyDirection = GameDirection.Top;

            if (newleft != 0)
                Left += newleft;
            else
                World.MovingElements.Remove(this);

            // away?
            if (runs >= 200 || Top > World.Settings.LevelHeight)
            {
                World.MovingElements.Remove(this);
            }
        }
Exemplo n.º 27
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (who == GameElement.MGO)
            {
                geventhandler(GameEvent.gotImmortialize, new Dictionary<GameEventArg, object>());
                World.MovingElements.Remove(this);
            }
        }
Exemplo n.º 28
0
 public static GameDirection Opposite(this GameDirection input)
 {
     return(GameDirectionHelper.Opposite(input));
 }
Exemplo n.º 29
0
 public static GameDirection Invert(this GameDirection input)
 {
     return(GameDirectionHelper.Invert(input));
 }
Exemplo n.º 30
0
        public override void Check(out Dictionary<string, float> newpos)
        {
            base.Check(out newpos);
            float newtop = newpos["top"];
            float newleft = newpos["left"];

            bool falling = false;
            if (distance < 120)
            {
                newtop -= Globals.MushroomMove.GO_Y * GameAI.FrameFactor;
                distance += Globals.MushroomMove.GO_Y * GameAI.FrameFactor;
            }
            else
            {
                // falling?
                falling = GamePhysics.Falling(World.StickyElements, World.MovingElements, World.Enemies, newtop, newleft, this);

                if (falling)
                    newtop += Globals.MushroomMove.GO_Y * GameAI.FrameFactor;
            }

            if (direction == GameDirection.Left)
                newleft -= Globals.MushroomMove.GO_X * GameAI.FrameFactor;
            else if (direction == GameDirection.Right)
                newleft += Globals.MushroomMove.GO_X * GameAI.FrameFactor;

            // check if direction is ok
            GamePhysics.CrashDetection(this, World.StickyElements, World.MovingElements, getEvent, ref newtop, ref newleft);

            // run in standing mgo?
            GameDirection _direction;
            if (GamePhysics.SingleCrashDetection(this, World.MGO, out _direction, ref newtop, ref newleft, true))
                GotMushroom();

            if (newtop != 0)
                Top += newtop;
            if (newleft != 0)
                Left += newleft;

            if (!falling && newleft == 0)
                direction = direction == GameDirection.Left ? GameDirection.Right : GameDirection.Left;

            // away?
            if (Top > World.Settings.LevelHeight)
                World.MovingElements.Remove(this);
        }
Exemplo n.º 31
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (got < canGet && DateTime.Now > canGetNext &&
                direction == GameDirection.Bottom && who == GameElement.MGO)
            {
                switch (btype)
                {
                    case BoxType.GoodMushroom:      getGoodie(BoxType.GoodMushroom);    break;
                    case BoxType.PoisonMushroom:    getGoodie(BoxType.PoisonMushroom);  break;
                    case BoxType.LiveMushroom:      getGoodie(BoxType.LiveMushroom);    break;
                    case BoxType.FireFlower:        getGoodie(BoxType.FireFlower);      break;
                    case BoxType.ModeDependent:
                        switch(World.MGO.Mode)
                        {
                            case MainGameObjectMode.Small:
                                getGoodie(BoxType.GoodMushroom); break;
                            case MainGameObjectMode.Normal:
                            case MainGameObjectMode.NormalFire:
                                getGoodie(BoxType.FireFlower); break;
                        }
                        break;

                    case BoxType.Star:              getGoodie(BoxType.Star);             break;
                    case BoxType.ImmortializeStar:  getGoodie(BoxType.ImmortializeStar); break;
                }

                got++;
                canGetNext = DateTime.Now.AddMilliseconds(200);
            }
        }
Exemplo n.º 32
0
 public GridPosDir(GridPos pos, GameDirection dir)
 {
     this.pos = pos;
     this.dir = dir;
 }
Exemplo n.º 33
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (who == GameElement.MGO)
            {
                if (base.Name != null && base.Name != "" && World.Script != null)
                    World.Script.callFunction(base.Name, "finishedLevel", geventhandler);

                Dictionary<GameEventArg, object> args = new Dictionary<GameEventArg, object>();
                args[GameEventArg.nextLevel] = nextLevel;
                args[GameEventArg.nextLevelStartAt] = startAt;

                geventhandler(GameEvent.finishedLevel, args);
            }
        }
Exemplo n.º 34
0
 public void Update(Draw d, GameDirection direction, float left, float top, int width, int height)
 {
     d.DrawImage(images[(int)direction, cur], left, top, width, height);
     if ((DateTime.Now - last).TotalMilliseconds >= milliSecPerFrame && Refresh)
     {
         cur++;
         last = DateTime.Now;
     }
     if (cur >= images.GetLength(1))
         cur = 0;
 }
Exemplo n.º 35
0
        public override bool getCrashEvent(GameObject go, GameDirection cidirection)
        {
            if (go is MainGameObject && cidirection == GameDirection.Top)
            {
                small = 2;
                return true;
            }

            return false;
        }
Exemplo n.º 36
0
 public static bool Within(this GameDirection input, GameDirection test)
 {
     return((input & test) == input);
 }
Exemplo n.º 37
0
 public virtual void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
 {
     if (base.Name != null && base.Name != "" && World.Script != null)
         World.Script.callFunction(base.Name, "onOver", geventhandler, who, direction);
 }
Exemplo n.º 38
0
        public override void onOver(GameEventHandler geventhandler, GameElement who, GameDirection direction)
        {
            base.onOver(geventhandler, who, direction);

            if (who == GameElement.MGO)
                GotMushroom();
        }
Exemplo n.º 39
0
 public override bool getCrashEvent(GameObject go, GameDirection cidirection)
 {
     return false;
 }
Exemplo n.º 40
0
 public SnakeEventArgs(List <GameObject> segments, GameDirection direction)
 {
     Segments  = new List <GameObject>(segments);
     Direction = direction;
 }
Exemplo n.º 41
0
 public static GameDirection RotateCCW(this GameDirection input)
 {
     return(GameDirectionHelper.RotateCCW(input));
 }
Exemplo n.º 42
0
        public override void Check(out Dictionary<string, float> newpos)
        {
            base.Check(out newpos);
            float newtop = newpos["top"];
            float newleft = newpos["left"];

            // falling?
            bool falling = GamePhysics.Falling(World.StickyElements, World.MovingElements, World.Enemies, newtop, newleft, this);

            if (falling)
                newtop += Globals.ObjFalling * GameAI.FrameFactor;

            if (turtleMode == TurtleMode.Small && (DateTime.Now - startSmall).Seconds >= 3)
            {
                TurtleMode = TurtleMode.Normal;
            }

            // direction
            if (!falling)
            {
                float move = 0;

                switch (turtleMode)
                {
                    case TurtleMode.Normal: move = Globals.Turtle.Normal * GameAI.FrameFactor; break;
                    case TurtleMode.Small: move = 0; break;
                    case TurtleMode.SmallRunning: move = Globals.Turtle.Fast * GameAI.FrameFactor; break;
                }

                if (direction == GameDirection.Right)
                    newleft += move;
                else
                    newleft -= move;
            }

            // check if direction is ok
            GamePhysics.CrashDetection(this, World.StickyElements, World.MovingElements, getEvent, ref newtop, ref newleft);
            Enemy crashedInEnemy = GamePhysics.CrashEnemy(this, World.Enemies, getEvent, ref newtop, ref newleft);

            bool removedEnemy = false;
            if (turtleMode == TurtleMode.SmallRunning && crashedInEnemy != null && crashedInEnemy.turtleCanRemove)
            {
                base.Remove(crashedInEnemy);
                removedEnemy = true;
            }

            // run in standing mgo?
            GameDirection _direction;
            if (GamePhysics.SingleCrashDetection(this, World.MGO, out _direction, ref newtop, ref newleft, true) && !getCrashEvent(this, _direction))
                World.MGO.getEvent(GameEvent.crashInEnemy, new Dictionary<GameEventArg, object>());

            if (newtop != 0)
                Top += newtop;
            if (newleft != 0)
                Left += newleft;

            if (!falling && (newleft == 0 || (crashedInEnemy != null && !removedEnemy)))
            {
                if (turtleMode == TurtleMode.Normal || turtleMode == TurtleMode.SmallRunning)
                    direction = direction == GameDirection.Left ? GameDirection.Right : GameDirection.Left;
            }

            // dead?
            if (Top > World.Settings.LevelHeight)
                base.Remove();
        }
Exemplo n.º 43
0
 public abstract bool getCrashEvent(GameObject go, GameDirection cidirection);
Exemplo n.º 44
0
        public override bool getCrashEvent(GameObject go, GameDirection cidirection)
        {
            if ((go is Enemy && go != this) || go is Mushroom)
                return true;

            if (cidirection == GameDirection.Top)
            {
                switch (turtleMode)
                {
                    case TurtleMode.Normal:
                        TurtleMode = TurtleMode.Small;
                        break;
                    case TurtleMode.Small:
                        TurtleMode = TurtleMode.SmallRunning;
                        break;
                    case TurtleMode.SmallRunning:
                        TurtleMode = TurtleMode.Small;
                        break;
                }
                startSmall = DateTime.Now;
                World.MGO.Move(MoveType.jumpTop, -1, false, GameInstruction.Nothing);

                return true;
            }
            else if (cidirection == GameDirection.Left || cidirection == GameDirection.Right)
            {
                if (turtleMode == TurtleMode.Small)
                {
                    turtleMode = TurtleMode.SmallRunning;
                    direction = cidirection == GameDirection.Left ? GameDirection.Right : GameDirection.Left;

                    return true;
                }
            }

            return false;
        }
Exemplo n.º 45
0
 public ActionStruct(GameAction action = GameAction.Idle, GameDirection direction = GameDirection.None)
 {
     this.action    = action;
     this.direction = direction;
 }
Exemplo n.º 46
0
    // Update is called once per frame
    void Update()
    {
        if (checks >= 5)
        {
            dm.EnablePressSpaceText();
        }

        if (replayMode)
        {
            if (replayFrameNumber < replayQueue.Count && rhythmUI.timeToBeat(Time.time) > replayQueue[replayFrameNumber].beat)
            {
                cluck         = replayQueue[replayFrameNumber].cluck;
                nextDirection = replayQueue[replayFrameNumber].nextDirection;

                replayFrameNumber++;
            }
        }
        else
        {
            if (cluck || nextDirection != GameDirection.none)
            {
                replayFrame frameData = new replayFrame();
                frameData.beat          = rhythmUI.timeToBeat(Time.time);
                frameData.cluck         = cluck;
                frameData.nextDirection = nextDirection;

                replayQueue.Add(frameData);

                if (cluck)
                {
                    if (Random.value < .5)
                    {
                        audio.PlayOneShot(squawk1);
                    }
                    else
                    {
                        audio.PlayOneShot(squawk2);
                    }
                }

                if (nextDirection == GameManager.GameDirection.chicken)
                {
                    if (Random.value < .5)
                    {
                        audio.PlayOneShot(clucks1);
                    }
                    else
                    {
                        audio.PlayOneShot(clucks2);
                    }
                }
            }
        }

        if (datingSimMode == true)
        {
            dm.cluck = cluck;
            cluck    = false;

            dm.nextDirection = nextDirection;
            nextDirection    = GameDirection.none;
            return;
        }


        if (cluck)
        {
            Debug.Log("cluck check");

            annoyedNPC = true;
            questionMark.Appear();
            cluck = false;
        }

        if (nextDirection != GameDirection.none)
        {
            checks++;

            if (nextDirection == GameDirection.romance || nextDirection == GameDirection.chicken || annoyedNPC)
            {
                SwitchToDatingSimMode();
            }
            if (nextDirection == GameDirection.spy)
            {
                switch (checks)
                {
                case 1:     //move to cubicle
                    spyMusic.volume     = 1f;
                    romanceMusic.volume = 0f;

                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(1, 3));
                    playerController.pushAction(PlayerController.Movement.action.crouchRight, 5);
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(1, 4));
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(2, 4));
                    playerController.pushAction(PlayerController.Movement.action.crouchRight, 5);
                    break;

                case 2:                             // duck behind file cabinet
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(3, 4));
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(3, 3));
                    playerController.pushAction(PlayerController.Movement.action.move, 4, new Vector2(5, 3));
                    playerController.pushAction(PlayerController.Movement.action.crouchLeft, 5);
                    break;

                case 3:                            // move to other cubicle
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(4, 3));
                    playerController.pushAction(PlayerController.Movement.action.move, 4, new Vector2(4, 1));
                    playerController.pushAction(PlayerController.Movement.action.move, 4, new Vector2(5, 1));
                    playerController.pushAction(PlayerController.Movement.action.crouchLeft, 5);
                    break;

                case 4:                            //duck behind potted plant
                    playerController.pushAction(PlayerController.Movement.action.move, 6, new Vector2(2, 1));
                    playerController.pushAction(PlayerController.Movement.action.wait, .5f);
                    playerController.pushAction(PlayerController.Movement.action.move, 1, new Vector2(4, 1));
                    playerController.pushAction(PlayerController.Movement.action.move, .5f, new Vector2(4, 0));
                    playerController.pushAction(PlayerController.Movement.action.crouchLeft, 1);
                    break;

                case 5:                            //move to file cabinet
                    playerController.pushAction(PlayerController.Movement.action.move, 2, new Vector2(4, 1));
                    playerController.pushAction(PlayerController.Movement.action.move, 1.5f, new Vector2(0, 1));
                    playerController.pushAction(PlayerController.Movement.action.crouchRight, 0);
                    break;
                }
            }

            nextDirection = GameDirection.none;
        }
    }
Exemplo n.º 47
0
        public override void Check(out Dictionary<string, float> newpos)
        {
            base.Check(out newpos);
            float newtop = newpos["top"];
            float newleft = newpos["left"];

            // falling?
            bool falling = GamePhysics.Falling(World.StickyElements, World.MovingElements, World.Enemies, newtop, newleft, this);

            if (falling)
                newtop += Globals.ObjFalling * GameAI.FrameFactor;

            // direction
            if (!falling)
            {
                switch (direction)
                {
                    case GameDirection.Left: newleft -= Globals.Gumba_X * GameAI.FrameFactor; break;
                    case GameDirection.Right: newleft += Globals.Gumba_X * GameAI.FrameFactor; break;
                }
            }

            // check if direction is ok
            GamePhysics.CrashDetection(this, World.StickyElements, World.MovingElements, getEvent, ref newtop, ref newleft);
            Enemy crashedInEnemy = GamePhysics.CrashEnemy(this, World.Enemies, getEvent, ref newtop, ref newleft);

            // run in standing mgo?
            GameDirection crashInDirection;
            if (GamePhysics.SingleCrashDetection(this, World.MGO, out crashInDirection, ref newtop, ref newleft, true) && !getCrashEvent(this, crashInDirection))
                World.MGO.getEvent(GameEvent.crashInEnemy, new Dictionary<GameEventArg, object>());

            if (newtop != 0)
                Top += newtop;
            if (newleft != 0)
                Left += newleft;

            if (!falling && newleft == 0 && direction != GameDirection.None)
            {
                direction = direction == GameDirection.Left ? GameDirection.Right : GameDirection.Left;
            }

            // dead?
            if (Top > World.Settings.LevelHeight)
                base.Remove();
        }
Exemplo n.º 48
0
 public dImage CurImage(GameDirection direction)
 {
     return images[(int)direction, cur];
 }