private void Move(Vector3 from, Vector3 to, float duration)
        {
            var parameters = new MoveParameters(from, to, duration);

            StopCoroutine("Move_Coroutine");
            StartCoroutine("Move_Coroutine", parameters);
        }
 public void Initialize(PlanerCore planer, MoveParameters parameters)
 {
     Agility = parameters.agility;
     m_direction = parameters.direction;
     m_planer = planer;
     m_planer.transform.rotation = Quaternion.identity;
     m_planer.transform.Rotate(new Vector3(0, -60 * m_direction, 0));
 }
Exemple #3
0
 public MarioCharacter(Texture2D[][] marioSpriteSheets, Vector2 location)
 {
     Mario             = new Mario(marioSpriteSheets, location);
     Parameters        = Mario.Parameters;
     InitialParameters = new MoveParameters(false);
     Scene.CopyDataOfParameter(Parameters, InitialParameters);
     Win       = false;
     DivedPipe = new ArrayList();
 }
 public EnemyCharacter(Texture2D[] texture, Point[] rowsAndColumns, MoveParameters moveParameters)
 {
     Parameters        = moveParameters;
     Parameters.IsLeft = Parameters.Position.X >= Sprint5Main.Game.Scene.Mario.GetMinPosition.X;
     Parameters.SetVelocity(2, 0);
     liveEnemy     = new AnimatedSprite(texture[0], rowsAndColumns[0], Parameters);
     diedEnemy     = new AnimatedSprite(texture[1], rowsAndColumns[1], Parameters);
     currentSprite = liveEnemy;
     disappear     = 100;
 }
 public PlantEnemyCharacter(Texture2D[] texture, Point[] rowsAndColumns, MoveParameters moveParameters) : base(texture, rowsAndColumns, moveParameters)
 {
     maxHeight = moveParameters.Position.Y - 30F;
     minHeight = moveParameters.Position.Y;
     Parameters.SetVelocity(0, 0);
     Type = Sprint5Main.CharacterType.Enemy;
     Parameters.HasGravity = false;
     ClockToWait           = 0;
     Appear = false; ReadyToTrigger = true;
 }
 public CloudEnemyCharacter(Texture2D[] texture, Point[] rowsAndColumns, MoveParameters moveParameters) : base(texture, rowsAndColumns, moveParameters)
 {
     Parameters.SetVelocity(0, 0);
     if (Parameters.Position.Y > 200)
     {
         Parameters.SetPosition(Parameters.Position.X, 100);
     }
     Parameters.HasGravity = false;
     Type = Sprint5Main.CharacterType.Enemy;
 }
Exemple #7
0
 public ItemCharacter(Texture2D texture, Point rowsAndColumns, Vector2 location)
 {
     Item             = new ItemSprite(texture, location, rowsAndColumns);
     Parameters       = Item.Parameters;
     InitialParameter = new MoveParameters(false);
     Scene.CopyDataOfParameter(Parameters, InitialParameter);
     IsBump   = false;
     BumpHigh = 0;
     BumpLow  = Sprint5Main.Game.GraphicsDevice.Viewport.Height;
 }
Exemple #8
0
 public Blocks(Texture2D sheet, MoveParameters moveParameters, Point rowAndColumn, BlockType type, ArrayList itemList)
     : base(sheet, rowAndColumn, moveParameters)
 {
     BType        = type;
     items        = itemList;
     containItems = itemList.Count != 0 ? true : false;
     bPosition    = moveParameters.Position;
     bStates      = new IBlockStates[4] {
         new HiddenState(), new NormalState(), new BumpingState(), new UsedOrDestroyedState()
     };
     currentbState = GenerateCurrentState();
     IsBumping     = false;
 }
        public ArrayList FactoryMethod(string name, Vector2 posS, Vector2 posE)
        {
            ArrayList list = new ArrayList();

            for (int x = 0; x < (posE.X - posS.X) / 16; x++)
            {
                for (int y = 0; y < (posE.Y - posS.Y) / 16; y++)
                {
                    Vector2        pos        = new Vector2(posS.X + x * 16, posS.Y + y * 16);
                    MoveParameters parameters = new MoveParameters(false);
                    parameters.SetPosition(pos.X, pos.Y);
                    switch (name)
                    {
                    case "Brick":
                        list.Add(GetBrickBlock(parameters, new ArrayList()));
                        break;

                    case "QuestionB":
                        list.Add(GetQuestionBlock(parameters, new ArrayList()));
                        break;

                    case "HiddenB":
                        list.Add(GetHiddenBlock(parameters, new ArrayList()));
                        break;

                    case "UsedB":
                        list.Add(GetUsedBlock(parameters));
                        break;

                    case "FloorB":
                        list.Add(GetFloorBlock(parameters));
                        break;

                    case "StairB":
                        list.Add(GetStairBlock(parameters));
                        break;

                    case "DestructibleStairB":
                        list.Add(GetDestructibleStairBlock(parameters));
                        break;

                    default: break;
                    }
                }
            }
            return(list);
        }
        private IEnumerator Move_Coroutine(MoveParameters parameters)
        {
            var from     = parameters.from;
            var to       = parameters.to;
            var duration = parameters.duration;

            var interpolant  = 0f;
            var lerpProgress = 0f;
            var lerpLength   = duration;

            while (lerpProgress < lerpLength)
            {
                rigidBody.position = Vector3.Lerp(from, to, interpolant);
                lerpProgress      += Time.deltaTime;
                interpolant        = lerpProgress / lerpLength;
                interpolant        = Mathf.Sin(interpolant * Mathf.PI * 0.5f);
                yield return(new WaitForFixedUpdate());
            }
        }
        private void ResetScene(bool resetAll, bool goToCheckPoint)
        {
            #region Reset
            //save backup
            MoveParameters tempParameter = new MoveParameters(true);
            Scene.CopyDataOfParameter(currScene.Mario.Parameters, tempParameter); //copy all state from Parameters
            //back up some special state which not included in Parameters
            bool Win = currScene.Mario.Win;
            //record the current Mode
            int preMode = Mode;

            ChangeToLoadingMode();
            scenes.Remove(currScene); //delete current level and remove it from level's list.
            //recreate a stage with initial state and connect it with current Scene.
            Stage stage = new Stage(Sprint5Main.Game);
            currScene.Stage = stage;
            scenes.Insert(CurrSceneIndex, currScene);
            //Initialize the scene and reload content.
            currScene.Initalize(CurrSceneIndex);
            currScene.LoadContent();
            Mode = preMode;
            //use backup to rewrite
            if (!resetAll) //Press [Rr] to reset all entities.
            {
                ChangeToNormalMode();
                currScene.Mario.Win = Win;
                Scene.CopyDataOfParameter(tempParameter, currScene.Mario.Parameters);
                currScene.Camera.LookAt(currScene.Mario.Parameters.Position);
            }
            else if (goToCheckPoint) //Mario died (with rest life > 1)
            {
                Scene.Mario.Parameters.SetPosition(CheckPoint, Scene.Mario.GetMinPosition.Y - 32);
            }
            else //Game Over or Win the game.
            {
                CheckPoint = Scene.Mario.GetMinPosition.X;
            }
            #endregion
        }
Exemple #12
0
        private float Clock;    // The Clock used for Died Animation

        public Mario(Texture2D[][] marioSpriteSheets, Vector2 location)
        {
            MarioState = new MarioState(this);
            //initialize position and velocity, where the MoveParameter itself will not do.
            Parameters = new MoveParameters(true);
            Parameters.SetPosition(location.X, location.Y);
            Parameters.SetVelocity(0, 0);
            JumpHigher = false; Dive = false; AutomaticallyMoving = false; Shoot = false; DiveRight = false;
            //store 13 Mario textures
            MarioSpriteSheets = marioSpriteSheets ?? throw new ArgumentNullException(nameof(marioSpriteSheets));
            ActionSprites     = new ISprite[6] {
                new AnimatedSprite(MarioSpriteSheets[0][0], new Point(1, 1), Parameters),
                new AnimatedSprite(MarioSpriteSheets[0][1], new Point(1, 1), Parameters),
                new AnimatedSprite(MarioSpriteSheets[0][2], new Point(1, 3), Parameters),
                new AnimatedSprite(MarioSpriteSheets[0][3], new Point(1, 1), Parameters),
                new AnimatedSprite(MarioSpriteSheets[0][1], new Point(1, 1), Parameters),
                new AnimatedSprite(MarioSpriteSheets[0][5], new Point(1, 1), Parameters)
            };
            FlagSprite    = new AnimatedSprite(MarioSpriteSheets[0][4], new Point(1, 1), Parameters);
            CurrentSprite = ActionSprites[0];
            Clock         = 0;
        }
 public JumpEnemyCharacter(Texture2D[] texture, Point[] rowsAndColumns, MoveParameters moveParameters) : base(texture, rowsAndColumns, moveParameters)
 {
 }
        public static IEnumerable <KeyValuePair <string, MoveData> > GetMoves(MoveParameters parameters)
        {
            var query = StaticData.Moves.AsEnumerable();

            if (!string.IsNullOrWhiteSpace(parameters.Name))
            {
                query = query.Where(x => string.Equals(x.Key, parameters.Name, StringComparison.CurrentCultureIgnoreCase));
            }

            if (parameters.Type.HasValue)
            {
                query = query.Where(x => x.Value.Type == parameters.Type.Value);
            }

            if (!string.IsNullOrWhiteSpace(parameters.MovePower))
            {
                query = query.Where(x => x.Value.MovePower?.Contains(parameters.MovePower) == true);
            }

            if (parameters.MoveTime.HasValue)
            {
                query = query.Where(x => x.Value.MoveTimeEnum == parameters.MoveTime.Value);
            }

            if (parameters.PPRange.Min.HasValue)
            {
                query = query.Where(x => x.Value.PowerPoints >= parameters.PPRange.Min);
            }

            if (parameters.PPRange.Max.HasValue)
            {
                query = query.Where(x => x.Value.PowerPoints <= parameters.PPRange.Max);
            }

            if (parameters.Duration.HasValue)
            {
                query = query.Where(x => x.Value.DurationEnum == parameters.Duration.Value);
            }

            if (parameters.IsConcentration.HasValue)
            {
                query = query.Where(x => x.Value.IsConcentration == parameters.IsConcentration.Value);
            }

            if (parameters.IsAttackRoll.HasValue)
            {
                query = query.Where(x => x.Value.IsAttackRoll == parameters.IsAttackRoll.Value);
            }

            if (parameters.HasSave.HasValue)
            {
                query = query.Where(x => !string.IsNullOrWhiteSpace(x.Value.Save));
            }

            if (parameters.IsTM.HasValue)
            {
                query = query.Where(x => StaticData.TMs.ContainsKey(x.Key));
            }

            if (parameters.ScalesWithLevel.HasValue)
            {
                query = parameters.ScalesWithLevel.Value
                    ? query.Where(x => x.Value.Damage != null)
                    : query.Where(x => x.Value.Damage == null);
            }

            return(query);
        }
 public Blocks(Texture2D sheet, Point rowAndCol, MoveParameters moveParameters, BlockType type) : base(sheet, rowAndCol, moveParameters)
 {
     bType = type;
 }
 //void Update(GameTime gameTime) { }
 public BackgroundCharacter(Texture2D texture, Vector2 pos)
 {
     Parameters = new MoveParameters(false);
     Parameters.SetPosition(pos.X, pos.Y);
     Background = new AnimatedSprite(texture, new Point(1, 1), Parameters);
 }
 public BlockCharacter GetFloorBlock(MoveParameters moveParameters)
 {
     return(new BlockCharacter(new FloorBlockSprite(BlockTextures[1], moveParameters)));
 }
Exemple #18
0
 public UsedBlockSprite(Texture2D texture, MoveParameters moveParameters) : base(texture, moveParameters, new Point(4, 1), BlockType.Used, new ArrayList {
 })
 {
 }
 public BlockCharacter GetBrickBlock(MoveParameters moveParameters, ArrayList items)
 {
     return(new BlockCharacter(new BrickBlockSprite(BlockTextures[0], moveParameters, items, BlockType.BNormal)));
 }
 public BlockCharacter GetHiddenBlock(MoveParameters moveParameters, ArrayList items)
 {
     return(new BlockCharacter(new HiddenBlockSprite(BlockTextures[0], moveParameters, items)));
 }
 public BlockCharacter GetQuestionBlock(MoveParameters moveParameters, ArrayList items)
 {
     return(new BlockCharacter(new QuestionBlockSprite(BlockTextures[3], moveParameters, items)));
 }
Exemple #22
0
 public FloorBlockSprite(Texture2D texture, MoveParameters moveParameters) : base(texture, moveParameters, new Point(4, 1), BlockType.Indestructible, new ArrayList())
 {
     // nothing to do
 }
 public BlockCharacter GetDestructibleStairBlock(MoveParameters moveParameters)
 {
     return(new BlockCharacter(new BrickBlockSprite(BlockTextures[4], moveParameters, new ArrayList(), BlockType.Used)));
 }
 public BlockCharacter GetStairBlock(MoveParameters moveParameters)
 {
     return(new BlockCharacter(new StairBlockSprite(BlockTextures[4], moveParameters)));
 }
Exemple #25
0
 public BrickBlockSprite(Texture2D texture, MoveParameters moveParameters, ArrayList items, BlockType type) : base(texture, moveParameters, new Point(4, 1), type, items)
 {
     destroyedBrickPosX = new float[4];
     destroyedBrickPosY = new float[4];
 }
Exemple #26
0
 public QuestionBlockSprite(Texture2D texture, MoveParameters moveParameters, ArrayList items) : base(texture, moveParameters, new Point(3, 4), BlockType.QNormal, items)
 {
 }
Exemple #27
0
 public FlightCameraController(string id, ControllerType controllerType,
                               MoveParameters moveParameters) : base(id, controllerType)
 {
     this.moveParameters = moveParameters;
 }
Exemple #28
0
 public HiddenBlockSprite(Texture2D texture, MoveParameters moveParameters, ArrayList items) : base(texture, moveParameters, items, BlockType.Hidden)
 {
 }
 public BlockCharacter GetUsedBlock(MoveParameters moveParameters)
 {
     return(new BlockCharacter(new UsedBlockSprite(BlockTextures[2], moveParameters)));
 }
Exemple #30
0
 public StairBlockSprite(Texture2D texture, MoveParameters moveParameters) : base(texture, moveParameters, new Point(4, 1), BlockType.Used, new ArrayList())
 {
     // nothing to do
 }
 public BossEnemyCharacter(Texture2D[] texture, Point[] rowsAndColumns, MoveParameters moveParameters) : base(texture, rowsAndColumns, moveParameters)
 {
     moveParameters.SetVelocity(2.0f, 0);
     currentSprite.FrameFreeze = true;
 }