Пример #1
0
        public LevelEditor()
        {
            //InputHelper.AddKey(Keys.Q);
            //InputHelper.AddKey(Keys.W);

            // just add all keys
            Keys[] allKeys = (Keys[])Enum.GetValues(typeof(Keys));
            foreach (var key in allKeys)
            {
                InputHelper.AddKey(key);
            }

            InputHelper.KeyRelease += new KeyHandler(KeyboardInput_KeyRelease);
            InputHelper.MouseMove  += new MouseMoveHandler(MouseInput_MouseMove);
            InputHelper.MouseDown  += new MouseClickHandler(MouseInput_MouseDown);
            InputHelper.MouseUp    += new MouseClickHandler(MouseInput_MouseUp);

            // tst actor navigation
            // Create behavior and the actor
            nav              = new BehaviorNav(0.2f);
            nav.GoalReached += new EventHandler(nav_GoalReached);

            bot          = new Actor("AI/arrow", Color.White);
            bot.Position = new Vector2(0, -380);
            bot.BehaviorList.Add(nav);
        } // LevelEditor()
Пример #2
0
        /// <summary> Create Red Arrow Enemy with arrow Texture </summary>
        public Enemy(Vector2 setPosition, int setHitPoints)
            : base("AI/arrow", new Color(255, 0, 0))
        {
            // Create animation
            _animationCogwheel = new Animation("Enemies/DerGeraet", 7, 5, 0, 32, 1000, true);
            //_animationCogwheel = new Animation("Enemies/cogwheel", 4, 12, 0, 48, 2000, true);
            _animationCogwheel.IsAlive = true;
            _animationCogwheel.Scale   = 0.3f;


            // Assign hitpoints and create rectangle from Texture
            HitPoints     = setHitPoints;
            body          = BodyFactory.CreateRectangle(PhysicsGameScreen.World, ConvertUnits.ToSimUnits(Texture.Width), ConvertUnits.ToSimUnits(Texture.Height), density);
            body.UserData = "enemy";


            // Create Behavior
            enemyNav              = new BehaviorNav(0.2f);
            enemyNav.GoalReached += new EventHandler(enemyNav_GoalReached);
            enemyNav.NodeReached += new EventHandler(enemyNav_NodeReached);
            BehaviorList.Add(enemyNav);

            // set Position and start navigation
            Position = setPosition;
            NavigateToActor(Node.GetClosestNode(setPosition));
        } // Enemy(Vector2 setPosition, int setHitPoints)