public AState saveGeneralData(AState inputState)
        {
            inputState.MDescription = "";
            ComboBox combobox = (ComboBox)canvas.Controls.Find("endGame", false).FirstOrDefault();

            inputState.MEndGame   = Convert.ToBoolean(combobox.SelectedItem);
            combobox              = (ComboBox)canvas.Controls.Find("endThread", false).FirstOrDefault();
            inputState.MEndThread = Convert.ToBoolean(combobox.SelectedItem);

            Label label = (Label)canvas.Controls.Find("labelID", false).FirstOrDefault();

            inputState.MID = Convert.ToUInt32(label.Text.Split()[2]);

            ListView NextStates = (ListView)canvas.Controls.Find("NextStates", false).FirstOrDefault();

            uint?[] s = new uint?[NextStates.Items.Count];
            for (int i = 0; i < NextStates.Items.Count; i++)
            {
                if (NextStates.Items[i].Text != "")
                {
                    s[i] = Convert.ToUInt32(NextStates.Items[i].Text);
                }
            }
            inputState.MNextStates = s;

            combobox          = (ComboBox)canvas.Controls.Find("originCombobox", false).FirstOrDefault();
            inputState.origin = Convert.ToInt32(combobox.Text.Split()[0]);

            combobox = (ComboBox)canvas.Controls.Find("parentThreadCombobox", false).FirstOrDefault();
            inputState.MParentThread = Convert.ToInt32(combobox.Text.Split()[0]);
            return(inputState);
        }
Пример #2
0
 protected override void HandleEnter(AState prevState)
 {
     m_Fan.SetConeActive(true);
     m_Fan.UnlockNavigation();
     m_Fan.SetAgentSpeed(ROAMING_SPEED);
     RandomizeTargetPoint();
 }
Пример #3
0
    public override void Enter(AState from)
    {
        inventoryCanvas.gameObject.SetActive(true);
//        missionPopup.gameObject.SetActive(false);


        k_UILayer = LayerMask.NameToLayer("UI");

        skyMeshFilter.gameObject.SetActive(true);
        UIGroundFilter.gameObject.SetActive(true);

        // Reseting the global blinking value. Can happen if the game unexpectedly exited while still blinking
        Shader.SetGlobalFloat("_BlinkingValue", 0.0f);

        if (MusicPlayer.instance.GetStem(0) != menuTheme)
        {
            MusicPlayer.instance.SetStem(0, menuTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }


        if (m_PowerupToUse != Consumable.ConsumableType.NONE)
        {
            //if we come back from a run and we don't have any more of the powerup we wanted to use, we reset the powerup to use to NONE
            if (!PlayerData.instance.consumables.ContainsKey(m_PowerupToUse) || PlayerData.instance.consumables[m_PowerupToUse] == 0)
            {
                m_PowerupToUse = Consumable.ConsumableType.NONE;
            }
        }

        Refresh();
    }
Пример #4
0
    public override void Enter(AState from)
    {
        if (player != null && player.isRetry)
        {
            OnRetry();
        }
        else
        {
            InstantiatePlayer();
        }

        manager.gameCamera.gameObject.SetActive(true);
        manager.gameCamera.GetComponent <CameraController>().target = player.gameObject;

        gameStateCanvas.gameObject.SetActive(true);
        UI.gameObject.SetActive(true);
        player.currentLife = 3;
        player.goalReached = false;

        levelHolder = GameObject.FindGameObjectWithTag("LevelHolder").transform;

        level = levelHolder.Find($"Level_{manager.indexLevelToLoad}").gameObject;

        try
        {
            InitLevel(manager.indexLevelToLoad);
        }
        catch (Exception ex)
        {
            Debug.LogError(string.Format("No level with that index bro ", ex));
        }
    }
Пример #5
0
    protected override void HandleLeave(AState nextState)
    {
        m_Mgr.SetGameTimerPause(false);
        m_Mgr.Player.SetInputLock(false);

        if (m_ConcertLocation.Type == ELocationType.Back)
        {
            POIManager.Instance.SetCutsceneCameraBackActive(false);
        }
        else
        {
            POIManager.Instance.SetCutsceneCameraAngleActive(false);
        }

        POIManager.Instance.GenerateMission(m_ConcertLocation.ID);
        GirlsManager.Instance.SetGirlsBlind(false);
        GirlsManager.Instance.SpawnGirl(5);
        GameManager.Instance.Player.LocomotionActive = true;
        m_ConcertLocation.Bejbe.Stop();
        m_ConcertLocation.Bejbe.volume = m_AudioVolume;

        m_ConcertLocation.Loop.Stop();
        m_ConcertLocation.Loop.volume = m_AudioVolume;

        m_ConcertLocation = null;
    }
    public override void Exit(AState to)
    {
        missionPopup.gameObject.SetActive(false);
        inventoryCanvas.gameObject.SetActive(false);

        if (m_Character != null)
        {
            Addressables.ReleaseInstance(m_Character);
        }

        GameState gs = to as GameState;

        skyMeshFilter.gameObject.SetActive(false);
        UIGroundFilter.gameObject.SetActive(false);

        if (gs != null)
        {
            gs.currentModifier = m_CurrentModifier;

            // We reset the modifier to a default one, for next run (if a new modifier is applied, it will replace this default one before the run starts)
            m_CurrentModifier = new Modifier();

            if (m_PowerupToUse != Consumable.ConsumableType.NONE)
            {
                PlayerData.instance.Consume(m_PowerupToUse);
                Consumable inv = Instantiate(ConsumableDatabase.GetConsumbale(m_PowerupToUse));
                inv.gameObject.SetActive(false);
                gs.trackManager.characterController.inventory = inv;
            }
        }
    }
Пример #7
0
    public override void Enter(AState from)
    {
        inventoryCanvas.gameObject.SetActive(true);
        missionPopup.gameObject.SetActive(false);

        charNameDisplay.text  = "";
        themeNameDisplay.text = "";

        k_UILayer = LayerMask.NameToLayer("UI");

        skyMeshFilter.gameObject.SetActive(true);
        UIGroundFilter.gameObject.SetActive(true);

        Shader.SetGlobalFloat("_BlinkingValue", 0.0f);

        if (MusicPlayer.instance.GetStem(0) != menuTheme)
        {
            MusicPlayer.instance.SetStem(0, menuTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }

        runButton.interactable = false;
        runButton.GetComponentInChildren <Text>().text = "Loading...";

        if (m_PowerupToUse != Consumable.ConsumableType.NONE)
        {
            if (!PlayerData.instance.consumables.ContainsKey(m_PowerupToUse) || PlayerData.instance.consumables[m_PowerupToUse] == 0)
            {
                m_PowerupToUse = Consumable.ConsumableType.NONE;
            }
        }

        Refresh();
    }
    public override void Enter(AState from)
    {
        //inventoryCanvas.gameObject.SetActive(true);
        // missionPopup.gameObject.SetActive(false);

        //charNameDisplay.text = "";
        //themeNameDisplay.text = "";

        k_UILayer = LayerMask.NameToLayer("UI");

        skyMeshFilter.gameObject.SetActive(true);
        //UIGroundFilter.gameObject.SetActive(true);

        // Reseting the global blinking value. Can happen if the game unexpectedly exited while still blinking
        Shader.SetGlobalFloat("_BlinkingValue", 0.0f);

        if (MusicPlayer.instance.GetStem(0) != menuTheme)
        {
            MusicPlayer.instance.SetStem(0, menuTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }

        runButton.interactable = false;
        runButton.GetComponentInChildren <Text>().text = "Loading...";

        Refresh();
    }
Пример #9
0
 public override void Enter(AState from)
 {
     menuUI.SetActive(true);
     CloudManager.spawnClouds = false;
     InitBgMusic();
     //Debug.Log("init bg music");
 }
Пример #10
0
    public override void Enter(AState from)
    {
        m_CountdownRectTransform = countdownText.GetComponent <RectTransform>();

        m_LifeHearts = new Image[k_MaxLives];

        for (int i = 0; i < k_MaxLives; ++i)
        {
            m_LifeHearts[i] = lifeRectTransform.GetChild(i).GetComponent <Image>();
        }


        if (MusicPlayer.instance.GetStem(0) != gameTheme)
        {
            MusicPlayer.instance.SetStem(0, gameTheme);
            CoroutineHandler.StartStaticCoroutine(MusicPlayer.instance.RestartAllStems());
        }


        m_AdsInitialised = false;

        m_GameoverSelectionDone = false;


        StartGame();
    }
Пример #11
0
    public void AddState(AState state)
    {
        state.SetParent(this);
        m_States[state.Id] = state;

        state.FSM.OnHierarchyChanged.AddListener(HandleHierarchyChanged);
    }
Пример #12
0
    public override void Enter(AState from)
    {
        if(from && from.GetName() == "Pause")
        {
            PauseBtnSetActive(true);
        }
        else
        {
            InitBgMusic();
            bgm.PlayAudio(gameMusic);

            InstantiateHero();
            score.Reset();

            SetupPlatformSpawnManager();

            //init camera follow
            SetCameraFollow(heroInstance.transform);

            CloudManager.spawnClouds = true;
            Debug.Log(string.Format("enter gameplay from {0}", from.GetName()));
        }

        //common actions
        Time.timeScale = gameSpeed;
        InGameUI.SetActive(true);
    }
    public override void Enter(AState from)
    {
        canvas.gameObject.SetActive(true);

        miniLeaderboard.playerEntry.inputName.text = PlayerData.instance.previousName;

        miniLeaderboard.playerEntry.score.text = trackManager.score.ToString();
        miniLeaderboard.Populate();

        if (PlayerData.instance.AnyMissionComplete())
        {
            StartCoroutine(missionPopup.Open());
        }
        else
        {
            missionPopup.gameObject.SetActive(false);
        }

        CreditCoins();

        if (MusicPlayer.instance.GetStem(0) != gameOverTheme)
        {
            MusicPlayer.instance.SetStem(0, gameOverTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }
    }
Пример #14
0
        private void findWays(thread th, AState state, string way)
        {
            if (state.MNextStates.Length != 0)
            {
                for (int i = 0; i < state.MNextStates.Length; i++)
                {
                    AState nextState = (AState)th.MIDToIState[state.MNextStates[i]];
                    string newString = way;
                    newString += state.buildText(i);
                    findWays(th, nextState, newString);
                }
            }
            else
            {
                if (!File.Exists("way0.txt"))
                {
                    File.Create("way0.txt");
                }

                StreamWriter sw = new StreamWriter("way0.txt", true, System.Text.Encoding.Default);
                sw.Write(way);
                sw.Close();
                ways++;
            }
        }
Пример #15
0
        public void OnCommHandle()
        {
            if (State.Count <= 0)
            {
                throw new EmptyStateException("Client doesn't have any state");
            }
            AState state = State.Peek();

            try
            {
                byte[] buffer = new byte[1024];
                int    len    = Socket.Receive(buffer);

                if (len == 0)
                {
                    Kill();
                    return;
                }

                state.ReadPacket(this, buffer, len);
            }
            catch (Exception e)
            {
                Alive = false;
            }
        }
Пример #16
0
    public override void Exit(AState to)
    {
        canvas.gameObject.SetActive(false);

        ClearPowerup();
        trackManager.End();
    }
Пример #17
0
        public override void drawInterface(AState inputState)
        {
            drawGeneralElements(inputState);
            stateDialogue tempStateDialogue = (stateDialogue)inputState;

            // specific elements
            // create  and fill phrasesList
            ListView phrasesList = new ListView();

            phrasesList.Name      = "phrasesList";
            phrasesList.Height    = canvas.Height - 40;
            phrasesList.Width     = canvas.Width / 3 * 2 - 20;
            phrasesList.Location  = new Point(canvas.Width / 3 + 10, 20);
            phrasesList.View      = View.Details;
            phrasesList.LabelEdit = true;
            phrasesList.MouseUp  += new MouseEventHandler(phrases_MouseUp);
            phrasesList.Columns.Add("Phrases", phrasesList.Width, HorizontalAlignment.Left);

            canvas.Controls.Add(phrasesList);
            foreach (Phrase ph in tempStateDialogue.MPhrases)
            {
                var listViewItem = new ListViewItem(ph.MPhrase);
                phrasesList.Items.Add(listViewItem);
            }
        }
Пример #18
0
 private void ChangeToState(AState state)
 {
     pc.animator.SetTrigger("T-SlideUp");
     pc.animator.SetBool("B-Slide", false);
     gc.uiController.SetOffTurboText();
     pc.ChangeState(state);
 }
Пример #19
0
        public override void Enter(AState from, GameObject[] args)
        {
            base.Enter(from);
            SceneManager.LoadScene("Main");

            rackDropped   = false;
            shovelDropped = false;
            axeDropped    = false;


            blocks = new NSLevel.Block[mapWidth, mapHeight];


            // GetComponent<NSLevel.Generator>().Generate();
            mapMat = new int[mapWidth, mapHeight];
            map    = new NSLevel.MapHandler(mapWidth, mapHeight, ref mapMat, percentWall);

            map.percentBordersAreWall = percentBorderWall;
            map.percentTree           = percentTree;
            map.Prepare();
            //NOT AS ADVERTISED
            map.RemoveInBetween();

            //map.PrintMap();


            // obsIDMat = GetComponent<NSLevel.Generator>().GetObsIDMatrix();

            Invoke("DoGenerateLevel", 1f);
        }
Пример #20
0
 protected override void HandleEnter(AState prevState)
 {
     UIManager.Instance.Messages.ShowFailMessage();
     m_Mgr.SetGameTimerPause(true);
     m_Mgr.Player.SetInputLock(true);
     m_Time = 1f;
 }
Пример #21
0
    public override void Exit(AState to)
    {
        loadoutCanvas.gameObject.SetActive(false);

        // Free resources
        //if (character != null) Addressables.ReleaseInstance(character);
    }
Пример #22
0
    public override void Enter(AState from)
    {
        canvas.gameObject.SetActive(true);

        lead.Score.text = "SCORE: " + trackManager.score.ToString();
        lead.BBTS.text  = "BBTS: " + trackManager.characterController.coins.ToString();


        //miniLeaderboard.playerEntry.inputName.text = PlayerData.instance.previousName;
        //miniLeaderboard.playerEntry.score.text = trackManager.score.ToString();
        //miniLeaderboard.Populate();

        //if (PlayerData.instance.AnyMissionComplete())
        //    missionPopup.Open();
        //else
        //    missionPopup.gameObject.SetActive(false);

        CreditCoins();

        if (MusicPlayer.instance.GetStem(0) != gameOverTheme)
        {
            MusicPlayer.instance.SetStem(0, gameOverTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }
    }
Пример #23
0
 void Awake()
 {
     Instance = this;
     nodes    = new List <RoadNode>();
     state    = new IdleState(this);
     mapGraph = new Graph();
 }
Пример #24
0
    public override void Exit(AState to)
    {
        missionPopup.gameObject.SetActive(false);
        inventoryCanvas.gameObject.SetActive(false);

        if (m_Character != null)
        {
            Destroy(m_Character);
        }

        GameState gamestate = to as GameState;

        skyMeshFilter.gameObject.SetActive(false);
        UIGroundFilter.gameObject.SetActive(false);

        if (gamestate != null)
        {
            gamestate.currentModifier = m_CurrentModifier;

            //重置人物选择的装饰为初始状态,为了下一次的游戏开始。
            m_CurrentModifier = new Modifier();
            //给游戏状态加载道具
            if (m_PowerupToUse != Consumable.ConsumableType.NONE)
            {
                PlayerData.instance.Consume(m_PowerupToUse);
                Consumable inventory = Instantiate(ConsumableDatabase.GetConsumable(m_PowerupToUse));
                inventory.gameObject.SetActive(false);
                gamestate.trackManager.characterController.inventory = inventory;
            }
        }
    }
Пример #25
0
 public override void Exit(AState to)
 {
     // Free resources (environment and enemies)
     gameOverPopup.gameObject.SetActive(false);
     gameOverCanvas.gameObject.SetActive(false);
     Destroy(winningGround.gameObject);
 }
Пример #26
0
 public void SolveMaze(string mazeName)
 {
     if (IsMazeExists(mazeName))
     {
         if (!IsSolutionExists(mazeName))
         {
             new Thread(() =>
             {
                 Maze3d maze3d           = m_mazes[mazeName];
                 ISearchable maze        = new SearchableMaze3d(maze3d);
                 AState startState       = maze.GetStartState();
                 ASearchingAlgorithm bfs = new BreadthFirstSearch();
                 Solution solution       = bfs.Solve(maze);
                 m_solutions.Add(mazeName, solution);
                 controller.output("solution for " + mazeName + " is ready");
             }).Start();
         }
         else
         {
             controller.output("solution for " + mazeName + " is ready");
         }
     }
     else
     {
         throw new Exception("maze " + mazeName + " dosen't exist!");
     }
 }
Пример #27
0
    public override void Enter(AState from)
    {
        loading.gameObject.SetActive(false);
        loadout.gameObject.SetActive(true);
        loadoutBackGroundStage.gameObject.SetActive(true);
        startGround.gameObject.SetActive(false);
        missionPopup.gameObject.SetActive(false);
        //BuyCharacterPopup.gameObject.SetActive(false);
        BuySkinPopup.gameObject.SetActive(false);

        charNameDisplay.text = "";
        //skinNameDisplay.text = "";
        //themeNameDisplay.text = "";

        //k_UILayer = LayerMask.NameToLayer("UI");

        //skyMeshFilter.gameObject.SetActive(true);
        //UIGroundFilter.gameObject.SetActive(true);

        // Reseting the global blinking value. Can happen if the game unexpectedly exited while still blinking
        //Shader.SetGlobalFloat("_BlinkingValue", 0.0f);


        if (MusicPlayer.instance.GetStem(0) != menuTheme)
        {
            MusicPlayer.instance.SetStem(0, menuTheme);
            StartCoroutine(MusicPlayer.instance.RestartAllStems());
        }


        startButton.interactable = false;
        startButton.GetComponentInChildren <Text>().text = "Loading...";

        /*
         * if (m_PowerupToUse != Consumable.ConsumableType.NONE)
         * {
         *  //if we come back from a run and we don't have any more of the powerup we wanted to use, we reset the powerup to use to NONE
         *  if (!PlayerData.instance.consumables.ContainsKey(m_PowerupToUse) || PlayerData.instance.consumables[m_PowerupToUse] == 0)
         *      m_PowerupToUse = Consumable.ConsumableType.NONE;
         * }
         */

        //charNameList = new List<string>(CharacterDatabase.dictionary.Keys);

        /*
         * foreach (KeyValuePair<string, Character> pair in CharacterDatabase.dictionary)
         * {
         *  string name = pair.Key;
         * }
         *
         * foreach (string name in charNameList)
         * {
         * }
         */
        charNum = PlayerData.instance.usedCharacter;
        skinNum = PlayerData.instance.usedSkin;
        cameraController.InLoadout();
        Refresh();
    }
Пример #28
0
 /*
  * // Start is called before the first frame update
  * void Start()
  * {
  *
  * }
  */
 public override void Enter(AState from)
 {
     Assert.IsNotNull(uiObj, "uiObj not found!");
     uiObj.SetActive(true);
     counter     = duration;
     counterText = uiObj.transform.Find("Countdown").gameObject.GetComponent <Text>();
     Assert.IsNotNull(counterText, "counterText not found!");
 }
Пример #29
0
    private void ChangeStateTo(AState state)
    {
        //zip.col.enabled = false;

        pc.isTirolina       = false;
        pc.transform.parent = null;
        pc.ChangeState(state);
    }
        public void addStateToThread(AState inState, int oldParentThread)
        {
            thread newThread = gc.getThread(inState.MParentThread);
            thread oldThread = gc.getThread(oldParentThread);

            oldThread.deleteState(inState.MID);
            newThread.addState(inState);
        }
Пример #31
0
 public void AddTransition(string stateLabel, AState state)
 {
     if(this.transitionStates.ContainsKey(stateLabel) == false) {
         this.transitionStates.Add(stateLabel, state);
     }
     else {
         Debug.LogError(stateLabel + " already exists as a transition state from " +this.stateLabel+ ".");
     }
 }
 /// <summary>
 /// Transitions the current state to its next state. Will not transition if the current state do not have any next state!
 /// </summary>
 public void TransitionTo(string stateLabel)
 {
     if(this.currentState.HasTransition(stateLabel)) {
         this.currentState.OnExit();
         this.currentState = this.currentState.GetTransitionState(stateLabel);
         this.currentState.OnEnter();
     }
     else {
         Debug.LogError("Transition state " +stateLabel+ " does not exist in " +this.currentState.GetLabel());
     }
 }
Пример #33
0
        public Enemy(Vector2f position, int direction, Element element)
        {
            float speed = Game.Rand.Next ((int)MIN_SPEED, (int)MAX_SPEED);
              int dir = UsefulTools.RandomPolarity ();
              Vector2f velocity = new Vector2f (dir * speed, 0);

              Init (position, velocity, element);

              HITBOX_INSET = new IntRect (31, 26, 34, 66);

              // Animation Stuff
              AnimationState = AState.Standing;
              VerticalState = VState.OnGround;

              UpdateHitbox ();

              ResetTimer ();
        }
Пример #34
0
        public PlayerObj(int playerNumber)
        {
            PlayerNumber = playerNumber;

              Element element = PlayerElements [PlayerNumber];
              Dimensions = DAO.GetSprite (element).TextureRect;
              Position = Controller.PlayerStartPos [PlayerNumber];

              Init (Position, new Vector2f (0, 0), element);

              // States
              AnimationState = AState.Standing;
              VerticalState = VState.OnGround;

              // Set Custom Hitbox
              HITBOX_INSET = new IntRect (32, 32, 32, 56);

              ActionPoint = new Vector2f (HITBOX_INSET.Width / 2, HITBOX_INSET.Height);
              UpdateHitbox ();

              ResetTimer ();
        }
Пример #35
0
 public void Carried(int playerNumber)
 {
     AnimationState = AState.Carried;
       IsCarried = true;
       CarriedByPlayerNumber = playerNumber;
 }
Пример #36
0
        public void PlayerShoots()
        {
            bool a = EnemyPushed != null && EnemyBeingCarried == null;
              bool b = EnemyBeingCarried != null;
              bool c = CurrentRopes > 0;

              if (a) {
            LiftEnemy ();
              } else if (b) {
            ThrowEnemy ();
              } else if (c) {
            Game.EventMgr.Notify (Event.ThrowRope, this);
            RemoveAvailableRope ();
            AnimationState = AState.Shooting;
              }
        }
Пример #37
0
 public void ResetPosition()
 {
     SetPosition (Controller.PlayerStartPos [PlayerNumber]);
       AnimationState = AState.Standing;
       VerticalState = VState.OnGround;
       Velocity.X = 0;
       Velocity.Y = 0;
       ResetShooting ();
 }
Пример #38
0
        public override void Update()
        {
            // Animation States
              if (AnimationState != AState.Shooting) {
            if (Math.Abs (Velocity.X) > 0)
              AnimationState = AState.Walking;
            else if (Velocity.X == 0)
              AnimationState = AState.Standing;
              }

              AnimationTick ();

              base.Update ();

              // Facing Direction
              if (Velocity.X < 0)
            Direction = -1;
              else if (Velocity.X > 0)
            Direction = 1;

              // Friction
              Velocity.X *= FRICTION;

              // Rounding
              if (Math.Abs (Velocity.X) < 0.5f)
            Velocity.X = 0;

              // Gravity
              Velocity.Y += GRAVITY;

              // Terminal Velocity
              if (Velocity.Y > TERMINAL_VELOCITY)
            Velocity.Y = TERMINAL_VELOCITY;
        }
Пример #39
0
 public void HitWithNet(int playerID)
 {
     switch (AnimationState) {
       case AState.Captured0:
     Stop ();
     AnimationState = AState.Captured1;
     ResetCapturedDuration ();
     break;
       case AState.Captured1:
     Stop ();
     AnimationState = AState.Captured2;
     ResetCapturedDuration ();
     break;
       case AState.Captured2:
     Stop ();
     ResetCapturedDuration ();
     break;
       case AState.Thrown:
     Stop ();
     break;
       default:
     Stop ();
     AnimationState = AState.Captured0;
     ResetCapturedDuration ();
     break;
       }
 }
Пример #40
0
 public bool Equals(AState stateToCheck)
 {
     return (attackState.Equals(stateToCheck));
 }
Пример #41
0
 public void SetAttackState(AState stateToSet)
 {
     attackState = stateToSet;
 }
Пример #42
0
 public void GetThrown()
 {
     Velocity.X = Direction * THROW_SPEED;
       Velocity.Y = 0;
       IsCarried = false;
       AnimationState = AState.Thrown;
 }
 public void SetInitialState(AState initialState)
 {
     this.initialState = initialState;
     this.currentState = initialState;
 }
Пример #44
0
        public override void Update()
        {
            // Animation States
              if (AnimationState == AState.Walking
            || AnimationState == AState.Standing) {

            if (Math.Abs (Velocity.X) > 0)
              AnimationState = AState.Walking;
            else if (Velocity.X == 0)
              AnimationState = AState.Standing;
              }

              AnimationTick ();

              base.Update ();

              int mapWidth = GameEngine.Level.Map.MapWidthPixels;
              int mapHeight = GameEngine.Level.Map.MapHeightPixels;

              if (HitBox.Left <= 0)
            Velocity.X *= -1;

              if (HitBox.Left + HitBox.Width >= mapWidth)
            Velocity.X *= -1;

              if (HitBox.Top <= 0)
            Velocity.Y *= -1;

              if (HitBox.Top + HitBox.Height >= mapHeight)
            Velocity.Y *= -1;

              // Facing Direction
              if (Velocity.X < 0)
            Direction = -1;
              else if (Velocity.X > 0)
            Direction = 1;

              // Gravity
              Velocity.Y += GRAVITY;

              if (Velocity.Y > TERMINAL_VELOCITY)
            Velocity.Y = TERMINAL_VELOCITY;

              // Animations
              IntRect srcRect = DstSprite.TextureRect;

              switch (AnimationState) {
              case AState.Standing:
            srcRect.Top = 0;
            break;
              case AState.Walking:
            srcRect.Top = 96;
            break;
            //      case AState.Jumping:
            //        break;
            //      case AState.Falling:
            //        break;
            //      case AState.Shooting:
            //        break;
              case AState.Captured0:
            srcRect.Top = 96 * 2;
            break;
              case AState.Captured1:
            srcRect.Top = 96 * 3;
            break;
              case AState.Captured2:
            srcRect.Top = 96 * 4;
            break;
              case AState.Carried:
            srcRect.Top = 96 * 4;
            break;
              case AState.Thrown:
            srcRect.Top = 96 * 4;
            break;
              }

              // Update Captured Counter
              if (AnimationState == AState.Captured0
            || AnimationState == AState.Captured1
            || AnimationState == AState.Captured2
            || AnimationState == AState.Thrown)
            CapturedDurationTick ();

              // Angry Color
              if (Angry)
            DstSprite.Color = new Color (255, 0, 0, 255);
              else
            DstSprite.Color = Color.White;

              if (AnimationState == AState.Standing
            || AnimationState == AState.Walking) {
            if (Angry)
              Velocity.X = ANGRY_MAX_SPEED * Direction;
            else
              Velocity.X = MAX_SPEED * Direction;
              }

              DstSprite.TextureRect = srcRect;
        }
Пример #45
0
        public void AnimationTick()
        {
            // Animation Timer
              if (Game.SystemTime - LastTick > TimerRate) {
            LastTick = Game.SystemTime;

            int state = 0;

            if (AnimationState == AState.Standing) {
              if (++Frame >= MAX_STAND_FRAMES) {
            Frame = 0;
            TimerRate = MAX_STANDING_RATE;
            if (Angry)
              TimerRate = MAX_ANGRY_STANDING_RATE;
            state = 0;
              }
            } else if (AnimationState == AState.Walking) {
              if (++Frame >= MAX_WALK_FRAMES) {
            Frame = 0;
            TimerRate = MAX_WALKING_RATE;
            if (Angry)
              TimerRate = MAX_ANGRY_WALKING_RATE;
            state = 1;
              }
            } else if (AnimationState == AState.Shooting) {
              if (++Frame >= MAX_SHOOT_FRAMES) {
            Frame = 0;
            AnimationState = AState.Standing;
            TimerRate = MAX_SHOOTING_RATE;
            if (Angry)
              TimerRate = MAX_ANGRY_SHOOTING_RATE;
            state = 2;
              }
            } else {
              Frame = 0;
              state = 0;
            }

            IntRect rect = DstSprite.TextureRect;
            rect.Left = Frame * Dimensions.Width;
            rect.Top = state * Dimensions.Height;

            DstSprite.TextureRect = rect;
              }
        }
Пример #46
0
 private void FreeEnemy()
 {
     AnimationState = AState.Standing;
       DstSprite.Rotation = 0;
       Angry = true;
       TimerRate = MAX_ANGRY_WALKING_RATE;
 }