Ejemplo n.º 1
0
        /// <summary>
        /// Initialize
        /// </summary>
        /// <returns>True if successful</returns>
        public override bool Initialize()
        {
            base.Initialize();

            mFlagOne = new EntityFlag(new Vector2((RB.SpriteSize().width * 2) - 1, (RB.SpriteSize().height * 3) + 8), RB.PLAYER_ONE);
            mFlagTwo = new EntityFlag(new Vector2(RB.DisplaySize.width - RB.SpriteSize().width - 8, (RB.SpriteSize().height * 3) + 8), RB.PLAYER_TWO);

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize
        /// </summary>
        /// <returns>True if successful</returns>
        public override bool Initialize()
        {
            base.Initialize();

            mPlayerOne = new EntityPlayer(new Vector2(RB.SpriteSheetGet().grid.cellSize.width * 2, 420), RB.PLAYER_ONE);
            mPlayerTwo = new EntityPlayer(new Vector2(((LEVEL_WIDTH - 1) * RB.SpriteSheetGet().grid.cellSize.width) - (RB.SpriteSheetGet().grid.cellSize.width * 2), 420), RB.PLAYER_TWO);

            mFlagOne = new EntityFlag(new Vector2(RB.SpriteSheetGet().grid.cellSize.width, (RB.SpriteSheetGet().grid.cellSize.height * 25) + 5), RB.PLAYER_ONE);
            mFlagTwo = new EntityFlag(new Vector2(((LEVEL_WIDTH - 2) * RB.SpriteSheetGet().grid.cellSize.width) - 8, (RB.SpriteSheetGet().grid.cellSize.height * 25) + 5), RB.PLAYER_TWO);

            mFlagOneSlot = new EntityFlagSlot(new Vector2((RB.SpriteSheetGet().grid.cellSize.width * 3) - 8, (RB.SpriteSheetGet().grid.cellSize.height * 25) + 5), RB.PLAYER_ONE);
            mFlagTwoSlot = new EntityFlagSlot(new Vector2((LEVEL_WIDTH - 4) * RB.SpriteSheetGet().grid.cellSize.width, (RB.SpriteSheetGet().grid.cellSize.height * 25) + 5), RB.PLAYER_TWO);

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            base.Update();
            if (Mathf.Abs(mPhysics.Velocity.x) > 0)
            {
                mFrameIndex += Mathf.Abs(mPhysics.Velocity.x) * mRunAnimSpeed;
                if (mFrameIndex >= mRunFrames.Length)
                {
                    mFrameIndex = 0;
                }
            }
            else
            {
                mFrameIndex = 0;
            }

            if (!mPhysics.IsOnGround)
            {
                mFrameIndex = 0;
            }

            int newFrameIndex = (int)mFrameIndex;

            if (mLastFrameIndex != newFrameIndex && (newFrameIndex == 1 || newFrameIndex == 3))
            {
                RB.SoundPlay(SuperFlagRun.SOUND_FOOT_STEP, 0.35f, Random.Range(0.7f, 1.3f));
            }

            mLastFrameIndex = newFrameIndex;

            SuperFlagRun game  = (SuperFlagRun)RB.Game;
            SceneGame    scene = (SceneGame)game.CurrentScene;

            if (mCarriedFlag == null && scene.GetWinner() == 0)
            {
                EntityFlag flag = scene.GetEnemyFlag(mPlayerNum);

                if (flag.ColliderInfo.Rect.Offset(new Vector2i((int)flag.Pos.x, (int)flag.Pos.y)).Intersects(ColliderInfo.Rect.Offset(new Vector2i((int)Pos.x, (int)Pos.y))))
                {
                    mCarriedFlag = flag;
                    RB.SoundPlay(SuperFlagRun.SOUND_PICKUP_FLAG);
                }
            }
            else if (mCarriedFlag != null)
            {
                if ((int)mFrameIndex == 1 || (int)mFrameIndex == 2)
                {
                    mCarriedFlag.Pos = new Vector2(Pos.x, Pos.y - 10);
                }
                else
                {
                    mCarriedFlag.Pos = new Vector2(Pos.x, Pos.y - 11);
                }

                if (scene.GetWinner() == 0)
                {
                    EntityFlagSlot flagSlot = scene.GetFlagSlot(mPlayerNum);
                    if (flagSlot.ColliderInfo.Rect.Offset(new Vector2i((int)flagSlot.Pos.x, (int)flagSlot.Pos.y)).Intersects(ColliderInfo.Rect.Offset(new Vector2i((int)Pos.x, (int)Pos.y))))
                    {
                        RB.SoundPlay(SuperFlagRun.SOUND_DROP_FLAG);
                        scene.SetWinner(mPlayerNum);
                        mCarriedFlag.Pos = flagSlot.Pos;
                        mCarriedFlag     = null;
                    }
                }
            }
        }