public async Task <bool> SwitchTo(State state)
        {
            // Don't do anything if we are in the correct state.
            if (state == GetState())
            {
                return(true);
            }

            // Put GameManager into state limbo to prevent state transitions.
            GameManagerParent.m_stateHandler = null;

            StateHandler result = await SwitchTo_Impl(state);

            if (result != null)
            {
                Debug.Assert(result.GetState() == state);
                GameManagerParent.m_stateHandler = result;
                return(true);
            }
            else
            {
                GameManagerParent.m_stateHandler = this;
                return(false);
            }
        }
Beispiel #2
0
 public bool NextToken()
 {
     fsm_context.Return = false;
     while (true)
     {
         StateHandler stateHandler = fsm_handler_table[state - 1];
         if (!stateHandler(fsm_context))
         {
             throw new JsonException(input_char);
         }
         if (end_of_input)
         {
             return(false);
         }
         if (fsm_context.Return)
         {
             break;
         }
         state = fsm_context.NextState;
     }
     string_value = string_buffer.ToString();
     string_buffer.Remove(0, string_buffer.Length);
     token = fsm_return_table[state - 1];
     if (token == 65542)
     {
         token = input_char;
     }
     state = fsm_context.NextState;
     return(true);
 }
        public SubStateDifficultySelect(StateAbstract theparent)
            : base(theparent)
        {
            int i;

            parent = theparent;
            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];

            colors = new Color[6];
            menu   = new string[6];

            menu[0] = "Child";
            menu[1] = "Youth";
            menu[2] = "Standard";
            menu[3] = "Challenging";
            menu[4] = "Expert";
            menu[5] = "Insane";

            for (i = 1; i < colors.Length; i++)
            {
                colors[i] = Color.DarkGray;
            }
            colors[0] = Color.White;

            mX     = 100;
            mY     = 45;
            width  = 900;
            height = 630;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true, true);
        }
Beispiel #4
0
 public bool NextToken()
 {
     this.fsm_context.Return = false;
     while (true)
     {
         StateHandler handler = fsm_handler_table[this.state - 1];
         if (!handler(this.fsm_context))
         {
             throw new JsonException(this.input_char);
         }
         if (this.end_of_input)
         {
             return(false);
         }
         if (this.fsm_context.Return)
         {
             this.string_value = this.string_buffer.ToString();
             this.string_buffer.Remove(0, this.string_buffer.Length);
             this.token = fsm_return_table[this.state - 1];
             if (this.token == 0x10006)
             {
                 this.token = this.input_char;
             }
             this.state = this.fsm_context.NextState;
             return(true);
         }
         this.state = this.fsm_context.NextState;
     }
 }
Beispiel #5
0
        public void Update(InputHandler input, StateHandler sh)
        {
            for (int i = 0; i < saveFileCount; i++)
            {
                this.playButtons[i].Update(input);
                this.deleteButtons[i].Update(input);

                if (deleteButtons[i].clicked)
                {
                    this.deleteButtons[i].clicked = false;
                    File.Delete(this.saveDir + saveNames[i] + ".ah");
                    this.Reload();
                }

                if (playButtons[i].clicked)
                {
                    this.playButtons[i].clicked = false;
                    sh.setCurState(State.GAME);
                    ((GameState)sh.curState).UpdateSaveData(PlayerSaver.LoadPlayerSaveFile(saveNames[i]));
                }
            }

            backButton.Update(input);

            if (backButton.clicked)
            {
                backButton.clicked = false;
                ((MenuState)sh.curState).curScreen = "main";
            }
        }
Beispiel #6
0
        public override void Update(StateHandler sh, GameTime gameTime)
        {
            this.keyboardState = Keyboard.GetState();
            this.mouseState    = Mouse.GetState();
            this.inputHandler.UpdateVars(this.keyboardState, this.mouseState);

            UpdateBackground(gameTime);


            switch (curScreen)
            {
            case "main":
                UpdateMainOptions(sh, gameTime, this.inputHandler);
                break;

            case "creation":
                UpdateCreationScreen(sh, gameTime, this.inputHandler);
                break;

            case "continue":
                UpdateContinueScreen(sh, gameTime, this.inputHandler);
                break;
            }

            if (this.keyboardState.IsKeyDown(Keys.F))
            {
                sh.setCurState(State.GAME);
            }
        }
Beispiel #7
0
 // Start is called before the first frame update
 void Start()
 {
     stateHandler = GetComponent <StateHandler>();
     collider     = GetComponent <BoxCollider2D>();
     rigidbody    = GetComponent <Rigidbody2D>();
     animator     = GetComponent <Animator>();
 }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
        public SubStateCharSelectSpell(SubStateAbstract theparent, SpellAbstract theSpell, PC thePC)
            : base(theparent)
        {
            spell = theSpell;
            curr  = thePC;
            int i = 0, alive = 0;

            for (i = 0; i < StateCombat.MonsterList.Length; i++)
            {
                if (StateCombat.MonsterList[i].Health > 0)
                {
                    alive++;
                }
            }

            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];
            colors       = new Color[3 + alive];
            menu         = new string[colors.Length];
            targets      = new Character[colors.Length];

            int unavailable = 0;

            for (i = 0; i < StateCombat.MonsterList.Length; i++)
            {
                if (StateCombat.MonsterList[i].Health < 1)
                {
                    unavailable++;
                }
                else
                {
                    targets[i - unavailable] = StateCombat.MonsterList[i];
                }
            }

            int index = 0;

            for (i = i - unavailable; i < targets.Length; i++, index++)
            {
                targets[i] = StateHandler.GetPC(index);
            }

            for (i = 0; i < menu.Length; i++)
            {
                menu[i] = targets[i].Name;
            }

            for (i = 1; i < colors.Length; i++)
            {
                colors[i] = Color.DarkGray;
            }
            colors[0] = Color.White;

            mX     = 250;
            mY     = 100;
            width  = 690;
            height = 510;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true);
        }//end EVC
        }//end input

        private void equipItem()
        {
            if (itemType == Globals.ITEM_TYPE_EQUIP)
            {
                if (itemID == ItemHandler.equipList.Count)
                {
                    unnequipItem();
                    parent = new SubStateListMenuEquip(parent.Parent, PCid, slot);
                    return;
                }
                if (StateHandler.GetPC(PCid).equipped[slot] != null)
                {
                    ItemHandler.equipList.Add(StateHandler.GetPC(PCid).equipped[slot]);
                }
                StateHandler.GetPC(PCid).equipped[slot] = ItemHandler.equipList[itemID];
                ItemHandler.equipList.RemoveAt(itemID);
                parent.Parent = new SubStateSlotMenuEquip((SubStateAbstract)parent.Parent.Parent, PCid);
            }
            else if (itemType == Globals.ITEM_TYPE_RUNE)
            {
                if (itemID == ItemHandler.runeList.Count)
                {
                    unnequipRune();
                    parent = new SubStateListMenuRune(parent.Parent, PCid, slot);
                    return;
                }
                if (StateHandler.GetPC(PCid).runes[slot] != null)
                {
                    ItemHandler.runeList.Add(StateHandler.GetPC(PCid).runes[slot]);
                }
                StateHandler.GetPC(PCid).runes[slot] = ItemHandler.runeList[itemID];
                ItemHandler.runeList.RemoveAt(itemID);
                parent.Parent = new SubStateSlotMenuRune((SubStateAbstract)parent.Parent.Parent, PCid);
            }
        }//end equipItem
Beispiel #11
0
 public void AddState(StateHandler state)
 {
     if (CurrentState != state)
     {
         _stack.Add(state);
     }
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageHandler"/> class.
 /// </summary>
 public MessageHandler()
 {
     this.nextStateHandler  = this.InitialStateHandler;
     this.RequiresFeedback  = false;
     this.AbortOnNeverMind  = true;
     this.DefaultConfidence = 1;
 }
Beispiel #13
0
        public TestState(StateHandler stateHandler) : base(stateHandler)
        {
            Random rnd = new Random();

            objects = new List <BasicRenderable>();
            for (int i = 0; i < 2; i++)
            {
                //-8.0f  - 8.0d
                //-4.5f  - 4.5f
                float x = rnd.Next(-8000, 8000) / 1000.0f;
                float y = rnd.Next(-4500, 4500) / 1000.0f;

                float r = (float)rnd.NextDouble();
                float g = (float)rnd.NextDouble();
                float b = (float)rnd.NextDouble();

                objects.Add(new BasicRenderable(1.0f, 1.0f, x, y, Color.FromArgb((int)(r * 255.0f), (int)(g * 255.0f), (int)(b * 255.0f))));
            }

            objects.Add(new BasicRenderable(0.5f, 0.5f, 1.0f, 0.0f, Color.AliceBlue));
            objects.Add(new BasicRenderable(0.25f, 0.25f, -8.0f, 0.0f, Color.LimeGreen));

            ControllableObject = new BasicRenderable(2.0f, 2.0f, Color.BlanchedAlmond);

            SpriteRenderables = new List <SpriteRenderable>();

            for (int i = 0; i < 4; i++)
            {
                float x = rnd.Next(-8000, 8000) / 1000.0f;
                float y = rnd.Next(-4500, 4500) / 1000.0f;

                SpriteRenderables.Add(new SpriteRenderable(1.3f, 2.0f, x, y, (Bitmap)Bitmap.FromFile("Textures//tex.png")));
            }
        }
        }//end EVC

        public override void Input(int input)
        {
            if (input == Globals.KEY_ACCEPT)
            {
                StateHandler.AddDelay();
                if (count == 0)
                {
                    //yes
                }
                else
                {
                    //no
                }
                StateHandler.State = Parent.Parent;
            }
            else if (input == Globals.KEY_CANCEL)
            {
                StateHandler.AddDelay();
                StateHandler.State = Parent;
            }
            else
            {
                base.Input(input);
            }
        }//end input
Beispiel #15
0
        public override void Render()
        {
            Terminal.Clear();
            StateHandler.Draw();
            AnimationHandler.Draw(_mapLayer);

            bool inMission = StateHandler.Peek().Match(
                some: state => !(state is MenuState) && !(state is IntermissionFrameState),
                none: () => false);

            if (inMission)
            {
                InfoPanel.Draw(_infoLayer);
                RadarPanel.Draw(_radarLayer);
                ObjectivePanel.Draw(_objectiveLayer);
                MessagePanel.Draw(_messageLayer);

                foreach (KeyValuePair <ISchedulable, int> kvp in EventScheduler._schedule)
                {
                    if (kvp.Key is DelayAttack da)
                    {
                        da.Draw(_mapLayer);
                    }
                }
            }

            Terminal.Refresh();
        }
Beispiel #16
0
        //Below: Specific update and draw methods for each step of the World Creation Process


        private void UpdateCharacterCreation(InputHandler input, StateHandler sh)
        {
            nameBox.Update(input);
            genderBoxes.Update(input);
            hairstyleList.Update(input);
            manaColorSlider.Update(input);
            skinColorSlider.Update(input);
            hairColorSlider.Update(input);
            shirtColorSlider.Update(input);

            charPrev.Update(genderBoxes.curSelectedID, hairstyleList.curElementID, manaColorSlider.curColor, skinColorSlider.curColor, hairColorSlider.curColor, shirtColorSlider.curColor);

            nextButton1.Update(input);
            backButton1.Update(input);

            if (backButton1.clicked)
            {
                backButton1.clicked = false;
                ((MenuState)sh.curState).curScreen = "main";
            }

            if (nextButton1.clicked)
            {
                nextButton1.clicked = false;
                this.curStep        = "stats";
            }
        }
Beispiel #17
0
 void Start()
 {
     if (GameObject.FindWithTag(Tags.persistentEngine) && GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>())
     {
         stateHandler = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>();
     }
 }
Beispiel #18
0
        private static void Render()
        {
            Terminal.Clear();
            Terminal.Layer(1);

            if (Player != null)
            {
                Map.Draw(_mapLayer);
                MessageHandler.Draw(_messageLayer);
                StatPanel.Draw(_statLayer);

                if (ShowInfo)
                {
                    InfoPanel.Draw(_leftLayer);
                }
                else
                {
                    LookPanel.Draw(_leftLayer);
                }

                if (ShowEquip)
                {
                    Player.Equipment.Draw(_rightLayer);
                }
                else
                {
                    Player.Inventory.Draw(_rightLayer);
                }
            }

            StateHandler.Draw();
            Animations.Draw();

            Terminal.Refresh();
        }
Beispiel #19
0
        public static void LoadGame()
        {
            if (!File.Exists(Constants.SAVE_FILE))
            {
                NewGame();
            }

            System.Diagnostics.Debug.WriteLine("Reading saved file");
            try
            {
                using (Stream saveFile = File.OpenRead(Constants.SAVE_FILE))
                {
                    BinaryFormatter deserializer = new BinaryFormatter();
                    World = (WorldHandler)deserializer.Deserialize(saveFile);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Load failed: {ex.Message}");
                NewGame();
            }

            // TODO: restore rng to saved position
            Random       = new PcgRandom(Option.FixedSeed ? Option.Seed : (int)DateTime.Now.Ticks);
            VisualRandom = new PcgRandom(Random.Next());
            StateHandler.Reset();
        }
        public SubStateSlotMenuEquip(SubStateAbstract theparent, int thePC)
            : base(theparent)
        {
            PCid = thePC;
            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];
            colors       = new Color[4];
            menu         = new string[4];

            for (int i = 0; i < 4; i++)
            {
                if (StateHandler.GetPC(thePC).GetEquipment(i) == null)
                {
                    menu[i] = "Open";
                }
                else
                {
                    menu[i] = StateHandler.GetPC(thePC).GetEquipment(i).Name;
                }
                colors[i] = Color.DarkGray;
            }

            colors[0] = Color.White;

            mX     = 170;
            mY     = 60;
            width  = 760;
            height = 490;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true);
        }//end EVC
        public SubStateConfirmEquipMenu(SubStateAbstract theparent, int xCoord, int yCoord, int thePC, int itemSlot, int itemLocation, int type)
            : base(theparent)
        {
            PCid     = thePC;
            slot     = itemSlot;
            itemID   = itemLocation;
            itemType = type;
            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];
            colors       = new Color[2];
            menu         = new string[2];

            menu[0] = "Yes";
            menu[1] = "No";

            colors[0] = Color.White;
            colors[1] = Color.DarkGray;

            mX     = xCoord;
            mY     = yCoord;
            width  = 27;
            height = 50;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true);
        }//end EVC
Beispiel #22
0
 private void OnDestroy()
 {
     stateHandler      = null;
     runtimeInventory  = null;
     playerInput       = null;
     playerInteraction = null;
 }
Beispiel #23
0
        public SubStateCharSelectMenuRune(SubStateAbstract theparent)
            : base(theparent)
        {
            parent = theparent;

            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];
            colors       = new Color[3];
            menu         = new string[3];

            menu[0] = StateHandler.GetPC(0).Name;
            menu[1] = StateHandler.GetPC(1).Name;
            menu[2] = StateHandler.GetPC(2).Name;

            colors[0] = Color.White;
            colors[1] = Color.DarkGray;
            colors[2] = Color.DarkGray;

            mX     = 100;
            mY     = 45;
            width  = 860;
            height = 590;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true);
        }//end EVC
        public SubStateOptionsMenu(StateAbstract theparent)
            : base(theparent)
        {
            int i;

            parent = theparent;
            StateHandler.AddDelay();
            messageBoxes = new MessageBox[1];

            colors = new Color[1];
            menu   = new string[colors.Length];

            colors[0] = Color.White;
            for (i = 1; i < colors.Length; i++)
            {
                colors[i] = Color.DarkGray;
            }

            menu[0] = "Difficulty";

            for (i = 1; i < menu.Length; i++)
            {
                menu[i] = "Option " + i;
            }

            mX     = 100;
            mY     = 45;
            width  = 900;
            height = 630;

            messageBoxes[0] = new MessageBox(mX, mY, width, height, menu, colors, true, true, true);
        }
Beispiel #25
0
 private void OnDestroy()
 {
     playerInput      = null;
     sceneSettings    = null;
     stateHandler     = null;
     runtimeInventory = null;
     player           = null;
 }
Beispiel #26
0
        public static void NewMission(MissionInfo info)
        {
            MessagePanel.Clear();
            AnimationHandler.Clear();

            SetupLevel(info);
            StateHandler.PushState(NormalState.Instance);
        }
Beispiel #27
0
        public Game()
        {
            _engine       = new EngineWindow();
            _stateHandler = new StateHandler(_engine.KeyboardInput);

            _engine.OnFrameRender += OnFrameRender;
            _engine.OnFrameUpdate += OnFrameUpdate;
        }
Beispiel #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageHandler"/> class.
 /// </summary>
 /// <param name="regexPattern">The regex pattern.</param>
 public MessageHandler(string regexPattern)
 {
     this.nextStateHandler  = this.InitialStateHandler;
     this.RequiresFeedback  = false;
     this.AbortOnNeverMind  = true;
     this.DefaultConfidence = 1;
     this.inputMatcher      = new InputMatcher(regexPattern);
 }
 public Parent(Model model,
               StateHandler env1Method,
               StateHandler notEnv1Method)
 {
     Model          = model;
     _env1Method    = env1Method;
     _notEnv1Method = notEnv1Method;
 }
 /// <summary>
 /// Initialise les gestionnaires de sorts et d'états.
 /// Par défaut, l'acteur peut bouger et lancer des sorts.
 /// </summary>
 /// <param name="position"> La position de l'acteur dans le monde </param>
 protected ControlledActor(Point position) : base(position)
 {
     _blockingMoves = 0;
     _blockingCasts = 0;
     SpellHandler   = new SpellHandler(this);
     _stateHandler  = new StateHandler(this);
     ResiduData     = new ResiduData(this, AnimationType.Death, false);
 }
Beispiel #31
0
 public void SwitchToRoaming(Attack attack)
 {
     attack.enabled = false;
     attIntervalCounter = attIntervalDelay;
     if (stationaryPosition != null)
         state = StationaryAttackIntervalIdle;
     else
         StartCoroutine (UpdateRoamPosition (10));
 }
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        current = this;

        // Start menu
        //state = GameState.STARTMENU;
        state = GameState.LEVELONE;
    }
Beispiel #33
0
        public ApplicationForm()
        {
            instance = this;
            this.ClientSize = new Size(1280, 720);

            this._stateHandler = new StateHandler(this);
            this._stateHandler.AddState(new MainView("MainView"));
            this._stateHandler.AddState(new FloorView("FloorView"));
            this._stateHandler.AddState(new ObjectView("ObjectView"));
            this._stateHandler.ActivateState("MainView");

            //Database init
            LocationHandler.GetInstance().LoadLocations();
            BuildingHandler.GetInstance().LoadBuildings();
            FloorHandler.GetInstance().LoadFromDatabase();
            RoomHandler.GetInstance().LoadFromDatabase();
            WallHandler.GetInstance().LoadFromDatabase();
            ItemHandler.GetInstance().LoadItems();

            DataTable data_walls = DatabaseHandler.GetInstance().SelectSQL(string.Format(@"Select `RoomID`, `WallID` FROM `RoomWall`"));
            if(data_walls != null && data_walls.Rows.Count > 0) {
                foreach(Room room in RoomHandler.GetInstance().GetAllRooms()) {
                    room.SaveChanges = false;
                    string wallIds = "";
                    foreach(DataRow row in data_walls.Rows) {
                        if(DatabaseUtil.parseInt(row, "RoomID") != room.GetID()) continue;
                        wallIds+= string.Format("{0}{1}", (wallIds.Length > 0 ? "," : ""), DatabaseUtil.parseInt(row, "WallID"));
                    }
                    if(wallIds.Length == 0) continue;

                    DataTable data_corners = DatabaseHandler.GetInstance().SelectSQL(string.Format(@"
                            SELECT `LeftPointID` as `PointID`
                            FROM `Wall`
                            WHERE `ID` in ({0})
                            UNION DISTINCT
                            SELECT `RightPointID` as `PointID`
                            FROM `Wall`
                            WHERE `ID` in ({0})
                        ", wallIds));
                    if(data_corners != null) {
                        room.GetCorners().Clear();
                        foreach(DataRow row_corners in data_corners.Rows) {
                            room.AddCorner(WallHandler.GetInstance().GetWallCornerByID(row_corners.Field<uint>("PointID")));
                        }
                    }
                    room.SaveChanges = true;
                    room.IsChanged = false;
                }
            }

            this.BackColor = Color.FromArgb(255, 32, 32, 32);

            this.Resize += this.EventResize;
        }
Beispiel #34
0
 void AttackIntervalIdle()
 {
     transform.LookAt (target.position);
     attIntervalCounter -= Time.deltaTime;
     if (navMeshAgent.remainingDistance == 0)
         StartCoroutine (UpdateRoamPosition (10));
     if (attIntervalCounter <= 0) {
         StopAllCoroutines ();
         state = Roaming;
     }
 }
Beispiel #35
0
    void Update()
    {
        state ();
        lastPosition = currentPosition;
        currentPosition = transform.position;

        lastRotation = currentRotation;
        currentRotation = transform.rotation;

        if (Input.GetKey(KeyCode.H))
            state = Moving;
    }
Beispiel #36
0
    void AttackIntervalIdle()
    {
        float distance = Vector3.Distance (transform.position, target.position);
        RaycastHit hit = SendRayDown ();
        Vector3 heightAdjustedPos = AdjustHeight (height, speed, hit);
        FollowTarget (heightAdjustedPos, roamTarget, speed);

        attIntervalCounter -= Time.deltaTime;
        if (transform.position.x == roamTarget.x && transform.position.z == roamTarget.z)
            StartCoroutine (UpdateRoamPosition (10));
        if (attIntervalCounter <= 0) {
            StopAllCoroutines();
            state = Roaming;
        }
    }
Beispiel #37
0
    void OnEnable()
    {
        NavMeshHit hit = new NavMeshHit();
        if (NavMesh.SamplePosition(transform.position, out hit, 100, 1)) {
            transform.position = hit.position;
            navMeshAgent = GetComponent<NavMeshAgent> ();
            navMeshAgent.enabled = true;
        } else {
            Debug.Log("shit");
        }

        flying = false;
        EnemyManager.instance.OnBuff += Buff;
        target = Player.instance.positionController.transform;

        attackManager = GetComponent<AttackManager> ();
        attackManager.collisionDetection.OnDeath += RemoveEvents;
        AreaEnemySpawner.instance.OnStateChange += RemoveEvents;
        EnemyManager.instance.NotifyNewEnemy (attackManager);
        Buff ();
        state = Roaming;
    }
Beispiel #38
0
 public void SwitchToIdle()
 {
     StopAllCoroutines ();
     state = Idle;
 }
Beispiel #39
0
    void OnEnable()
    {
        flying = true;
        EnemyManager.instance.OnBuff += UpdateBarriers;
        EnemyManager.instance.OnBuff += Buff;
        target = Player.instance.positionController.transform;
        attackManager = GetComponent<AttackManager> ();
        attackManager.collisionDetection.OnDeath += RemoveEvents;
        AreaEnemySpawner.instance.OnStateChange += RemoveEvents;
        EnemyManager.instance.NotifyNewEnemy (attackManager);

        barrierSpawner = GetComponent<BarrierSpawner> ();
        turretBarrierSpawner = GetComponent<TurretBarrierSpawner> ();
        UpdateBarriers ();
        Buff ();

        if (stationaryPosition != null)
            state = StationaryRoaming;
        else
            state = Roaming;
    }
Beispiel #40
0
 void OnTriggerEnter(Collider _collider)
 {
     transform.position = lastPosition;
     transform.rotation = lastRotation;
     state = Stopped;
 }
Beispiel #41
0
    IEnumerator Fire(GameObject _chargeEffect, GameObject projectile, Vector3 position, float damage, float knockback, float chargeDelay, StateHandler methodToCall = null)
    {
        GameObject particles = (GameObject)Instantiate(_chargeEffect, position, transform.rotation);
        particles.transform.parent = transform;
        float chargeCounter = chargeDelay;

        while (chargeCounter > 0) {

            chargeCounter -= Time.deltaTime;
            transform.LookAt (target.position);
            yield return null;
        }
        FireProjectile (position, damage, knockback, projectile);
        if (methodToCall != null)
            methodToCall ();
    }
Beispiel #42
0
        private static void PopulateFsmTables(out StateHandler[] fsm_handler_table, out int[] fsm_return_table)
        {
            // See section A.1. of the manual for details of the finite
            // state machine.
            fsm_handler_table = new StateHandler[28] {
                State1,
                State2,
                State3,
                State4,
                State5,
                State6,
                State7,
                State8,
                State9,
                State10,
                State11,
                State12,
                State13,
                State14,
                State15,
                State16,
                State17,
                State18,
                State19,
                State20,
                State21,
                State22,
                State23,
                State24,
                State25,
                State26,
                State27,
                State28
            };

            fsm_return_table = new int[28] {
                (int) ParserToken.Char,
                0,
                (int) ParserToken.Number,
                (int) ParserToken.Number,
                0,
                (int) ParserToken.Number,
                0,
                (int) ParserToken.Number,
                0,
                0,
                (int) ParserToken.True,
                0,
                0,
                0,
                (int) ParserToken.False,
                0,
                0,
                (int) ParserToken.Null,
                (int) ParserToken.CharSeq,
                (int) ParserToken.Char,
                0,
                0,
                (int) ParserToken.CharSeq,
                (int) ParserToken.Char,
                0,
                0,
                0,
                0
            };
        }
Beispiel #43
0
 void Start()
 {
     currentPosition = transform.position;
     currentRotation = transform.rotation;
     state = Moving;
 }
	private void OnDestroy ()
	{
		stateHandler = null;
		playerInput = null;
	}
	private void Start ()
	{
		ResetTarget ();

		Vector3 angles = transform.eulerAngles;
		roll = angles.x; 
		spin = angles.y;

		if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
		{
			stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
		}

		Update ();
	}
Beispiel #46
0
    IEnumerator UpdateRoamPosition(float radius)
    {
        state = Idle;
        Vector3 position = Vector3.zero;
        while (position == Vector3.zero) {
            Vector2 position2D = Random.insideUnitCircle * radius;
            position = target.position;
            position.x += position2D.x;
            position.z += position2D.y;

            RaycastHit hit;
            Physics.Raycast (position, Vector3.down, out hit, Mathf.Infinity);
            position = hit.point;
            yield return null;
        }
        navMeshAgent.SetDestination (position);
        state = AttackIntervalIdle;
    }
Beispiel #47
0
 public void SwitchToIdle()
 {
     StopAllCoroutines ();
     Destroy (navMeshAgent);
     state = Idle;
 }
Beispiel #48
0
 void SwitchToAttacking()
 {
     navMeshAgent.Stop ();
     state = Idle;
     if (attackManager.EnableAttack (attackManager.availableAttacks) == null)
         state = Roaming;
 }
Beispiel #49
0
 void SwitchToAttacking()
 {
     state = Idle;
     if (attackManager.EnableAttack (attackManager.availableAttacks) == null) {
         if (stationaryPosition != null)
             state = StationaryRoaming;
         else
             state = Roaming;
     }
 }