// Use this for initialization
    protected override void Start()
    {
        Sight    = GetComponent <FieldOfView>();
        Search   = GetComponent <AStarSearch>();
        Path     = GetComponent <ASPathFollower>();
        Wander   = GetComponent <Wander>();
        Flee     = GetComponent <Flee>();
        Face     = GetComponent <Face>();
        Agent    = GetComponent <Agent>();
        Animator = GetComponent <Animator>();

        Terrain     = GameObject.Find("Terrain");
        SearchAgent = GetComponent <ASAgent>();
        herdCentre  = GameObject.Find("HerdCentre").gameObject;

        Path.enabled = true;
        Path.path    = new ASPath();
        Path.enabled = false;

        State = new FiniteStateMachine <Ankylosaurus>(this);
        State.Change(Idle.Instance);

        collision_time = 0.0f;
        health_time    = 0.0f;
        hunger_time    = 0.0f;
        thirst_time    = 0.0f;

        base.Start();
    }
Beispiel #2
0
    // Use this for initialization
    protected override void Start()
    {
        Sight   = GetComponent <FieldOfView>();
        Search  = GetComponent <AStarSearch>();
        Path    = GetComponent <ASPathFollower>();
        Wander  = GetComponent <Wander>();
        Seek    = GetComponent <Seek>();
        Flee    = GetComponent <Flee>();
        Arrive  = GetComponent <Arrive>();
        Terrain = GameObject.Find("Terrain");

        Animator    = GetComponent <Animator>();
        SearchAgent = GetComponent <ASAgent>();

        State = new FiniteStateMachine <Velociraptor>(this);
        State.Change(V_Idle.Instance);

        Path.enabled = true;
        Path.path    = new ASPath();
        Path.enabled = false;

        collision_ticks = 0.0f;
        health_time     = 0.0f;
        hunger_time     = 0.0f;
        thirst_time     = 0.0f;

        base.Start();
    }
 void changeState(FSMState <DragonItemsManager> e)
 {
     FSM.Change(e);
     runResources();
 }
 void changeState(FSMState <SkillController> e)
 {
     FSM.Change(e);
     runResources();
 }
 void changeState(FSMState <SelectDragonController> e)
 {
     FSM.Change(e);
     runResources();
 }
Beispiel #6
0
 void changeState(FSMState <ObjectController> e)
 {
     FSM.Change(e);
     runResources();
 }
Beispiel #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Contents.LoadAll(Content, GraphicsDevice);
            #region InstantiateGraphicalContent

            // Fps
            fpsText = new Text("fps", 0, 0, "" + fps, () => { gameConsole.Log("Clicked me"); });

            time     = new Time();
            timeText = new Text(time.ToString());

            // (Content of this region is only meant for debugging purposes.)
            #region Test

            //Character adventurer = new Character("adventurer", isPlayerControlled: true,
            //    keyboardInput: KeyboardInput.Default(),
            //    animatedSprite: SpriteFactory.Adventurer(Vector2.Zero));

            //Character swordsman = new Character("swordsman", isPlayerControlled: true,
            //    keyboardInput: KeyboardInput.Alternative(),
            //    animatedSprite: SpriteFactory.Swordsman(Vector2.Zero));

            Random rnd = new Random();

            Character[] chars = new Character[30];
            for (int i = 0; i < chars.Length; i++)
            {
                if (i % 2 == 0)
                {
                    chars[i] = new Character("Char" + i, isPlayerControlled: true,
                                             keyboardInput: KeyboardInput.Default(),
                                             animatedSprite: SpriteFactory.Swordsman(new Vector2(rnd.Next(0, 3240), rnd.Next(0, 2160))));
                }
                else
                {
                    chars[i] = new Character("Char" + i, isPlayerControlled: true,
                                             keyboardInput: KeyboardInput.Alternative(),
                                             animatedSprite: SpriteFactory.Swordsman(new Vector2(rnd.Next(0, 3240), rnd.Next(0, 2160))));
                }
            }

            CollisionManager collisionManager = new CollisionManager();
            foreach (Character c in chars)
            {
                collisionManager.Collidables.Add(c.AnimatedSprite);
            }

            List <IEntity> entities = new List <IEntity>();
            entities.Add(collisionManager);
            foreach (Character c in chars)
            {
                entities.Add(c.AnimatedSprite);
            }

            finiteStateMachine = new FiniteStateMachine(new Dictionary <EState, State>()
            {
                { EState.EmptyState, new EmptyState(new List <EState>()
                    {
                        EState.MainMenuState
                    }) },
                { EState.MainMenuState, StateFactory.DefaultMainMenuState() },
                { EState.TestLevelState, StateFactory.TestLevelState(entities.ToArray()) },
                { EState.InventoryState, StateFactory.InventoryState(chars) }
            });
            finiteStateMachine.Change(EState.MainMenuState);

            #endregion

            #endregion
        }