public void AddEntity(MarauderEngine.Entity.Entity entity)
            {
                if (members != null)
                {
                    //members.Add(entity);
                    int x = ((int)entity.GetComponent <TransformComponent>().Position.X % (16 * 128)) / 128;
                    int y = ((int)entity.GetComponent <TransformComponent>().Position.Y % (16 * 128)) / 128;

                    members[x, y] = entity;
                }
                else
                {
                    members = new MarauderEngine.Entity.Entity[16, 16];
                    //for(int y = 0; y < members.GetLength(1); y++)
                    //{
                    //    for(int x = 0; x < members.GetLength(0); x++)
                    //    {
                    //        members[x, y] = new MarauderEngine.Entity.Entity();
                    //    }
                    //}
                    x = entity.cellX;
                    y = entity.cellY;
                    AddEntity(entity);
                }
            }
Example #2
0
        public PhysicsComponent(MarauderEngine.Entity.Entity owner)
        {
            RegisterComponent(owner, "PhysicsComponent");

            //RegisterPhysicsBody();
            //Collider.CollidedWithEntity += OnCollision;
        }
Example #3
0
        /// <summary>
        /// Creates a ray
        /// </summary>
        /// <param name="entity">the entity that sends the "Ray" event</param>
        /// <param name="position">the position that the ray extends from </param>
        /// <param name="distance">the distance that the ray travels from</param>
        /// <param name="angle">the angle of the ray</param>
        /// <param name="step">the step that the ray takes</param>
        /// <returns></returns>
        public bool MakeRay(MarauderEngine.Entity.Entity entity, Vector2 position, int distance, float angle, int step = 5)
        {
            points = new List <Point>();
            float cosX = (float)(Math.Cos(angle));
            float cosY = (float)(Math.Sin(angle));

            for (int i = 0; i < distance; i += step)
            {
                int x = (int)(cosX * i) + (int)position.X;
                int y = (int)(cosY * i) + (int)position.Y;

                Point rayPoint = new Point(x, y);
                //Console.WriteLine(rayPoint);
                rayP1 = rayPoint;
                rayEvent.parameters["Ray"] = rayPoint;

                points.Add(rayPoint);
                //Game1.world.FireGlobal()
                if (SceneManagement.CurrentScene.FireGlobalEvent(rayEvent, entity))
                {
                    //Console.WriteLine("hit " + rayPoint  + " "+ Game1.world.FireGlobalEvent(rayEvent, entity));
                    hit = rayPoint;
                    return(true);
                }
            }
            //Console.WriteLine("didnt hit " + false);
            return(false);
        }
 /// <summary>
 /// Adds a dynamic entity to the proper cell
 /// </summary>
 /// <param name="entity"></param>
 public void AddDynamicEntity(MarauderEngine.Entity.Entity entity)
 {
     entity.SetPartitionCell(PositionToCell(entity).X, PositionToCell(entity).Y);
     entity.SetCellIndex(PositionToIndex(entity.GetComponent <TransformComponent>().Position));
     dynamicCells[PositionToIndex(entity)].AddEntity(entity);
     //Console.WriteLine("Added dynamic entity of type " + entity.GetType());
 }
        /// <summary>
        /// changes vector to to a cell point
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Point PositionToCell(MarauderEngine.Entity.Entity entity)
        {
            int cellX = ((int)(entity.GetEntityPosition().X - offset.X) / (partitionSize * ((partitionSize * partitionSize) * 8)) / partitionSize);
            int cellY = ((int)(entity.GetEntityPosition().Y - offset.Y) / (partitionSize * ((partitionSize * partitionSize) * 8)) / partitionSize);

            return(new Point(cellX, cellY));
        }
        public BodyComponent(MarauderEngine.Entity.Entity entity)
        {
            RegisterComponent(entity, "BodyComponent");

            _transformComponent = Owner.GetComponent <TransformComponent>();

            body = new Body();

            body.AddBodyPart(new Torso(3, Vector2.Zero)
            {
                lerpSpeed = .2f,
                turnAngle = 25,
                scale     = 1
            });

            body.AddBodyPart(new Head(1, new Vector2(-22, 0))
            {
                lerpSpeed = .2f,
                turnAngle = 5,
                scale     = 1f
            });
            body.AddBodyPart(new Hand(2, new Vector2(30, -44))
            {
                scale = 1.3f,
                // try 25 for lols
                lerpSpeed = .1f,
                turnAngle = 10
            });
            body.AddBodyPart(new Hand(2, new Vector2(30, 44))
            {
                scale     = 1.3f,
                lerpSpeed = .1f,
                turnAngle = 10
            });
        }
Example #7
0
 public override void RegisterComponent(MarauderEngine.Entity.Entity entity, string componentName)
 {
     Name            = componentName;
     Owner           = entity;
     Active          = true;
     this._rectangle = Owner.collisionRectanlge;
 }
Example #8
0
        /// <summary>
        /// Creates the ray
        /// </summary>
        /// <param name="entity">entity making the ray</param>
        /// <param name="distance">max distance</param>
        /// <param name="step">incremental checks</param>
        /// <returns></returns>
        public bool MakeRay(MarauderEngine.Entity.Entity entity, int distance, int step = 5)
        {
            points = new List <Point>();
            float cosX = (float)(Math.Cos(Microsoft.Xna.Framework.MathHelper.ToRadians(angle)));
            float cosY = (float)(Math.Sin(Microsoft.Xna.Framework.MathHelper.ToRadians(angle)));

            for (int i = 0; i < distance; i += step)
            {
                int x = (int)(cosX * i) + (int)entity.GetComponent <TransformComponent>().Position.X;
                int y = (int)(cosY * i) + (int)entity.GetComponent <TransformComponent>().Position.Y;

                Point rayPoint = new Point(x, y);

                rayP1 = rayPoint;

                rayEvent.parameters["Ray"] = rayPoint;

                points.Add(rayPoint);
                //Game1.world.FireGlobal()
                if (SceneManagement.CurrentScene.FireGlobalEvent(rayEvent, entity))
                {
                    //Console.WriteLine("hit " + rayPoint  + " "+ Game1.world.FireGlobalEvent(rayEvent, entity));
                    hit = rayPoint;
                    return(true);
                }
            }
            //Console.WriteLine("didnt hit " + false);
            return(false);
        }
Example #9
0
 /// <summary>
 /// Update with the Entity
 /// </summary>
 /// <param name="entity"></param>
 public void Update(MarauderEngine.Entity.Entity entity)
 {
     if (_state.Update(entity) != null)
     {
         _state = _state.Update(entity);
         _state.EnterState(entity);
     }
 }
Example #10
0
        /// <summary>
        /// The Enter State
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public IState EnterState(MarauderEngine.Entity.Entity entity)
        {
            //// find plan
            //entity.actionPlan = entity.planner.plan(entity.GetWorldState(), entity.GetGoalState());

            //if (entity.actionPlan != null && entity.actionPlan.Count > 0)
            //{
            //    return ExitState(Entity.Entity);
            //}
            //else
            //{
            //    return null;
            //}

            return(null);
        }
 public void AddEntity(MarauderEngine.Entity.Entity entity)
 {
     if (members != null)
     {
         members.Add(entity);
         //Console.WriteLine("added " + entity);
     }
     else
     {
         members = new List <MarauderEngine.Entity.Entity>
         {
             entity
         };
         //Console.WriteLine("added " + entity);
     }
 }
Example #12
0
        public IState EnterState(MarauderEngine.Entity.Entity entity)
        {
            //var action = entity.actionPlan.Peek().name;

            //switch (action)
            //{
            //    case "sleep":
            //    {
            //        // navigate to
            //        //entity.FindPathTo(new Vector2());
            //        break;
            //    }
            //}

            throw new NotImplementedException();
        }
            public void RemoveEntity(MarauderEngine.Entity.Entity entity)
            {
                if (members != null)
                {
                    for (int i = 0; i < members.Count; i++)
                    {
                        //Console.WriteLine("trying to remove entity...");
                        if (members[i].id == entity.id)
                        {
                            //members[i].DestroyEntity();
                            members.RemoveAt(i);

                            //Console.WriteLine("removed " + entity);
                        }
                    }
                }
            }
        /// <summary>
        /// Changes cell property from one cell to another
        /// </summary>
        /// <param name="entity"></param>
        public void ChangeCell(MarauderEngine.Entity.Entity entity)
        {
            if (EntityWithinBounds(entity.cellIndex))
            {
                if (dynamicCells[entity.cellIndex].members != null)
                {
                    //int i = PositionToIndex(entity);
                    //if (i >= 0 && i < cellLength)
                    //{
                    //    dynamicCells[i].AddEntity(entity);

                    //}
                    dynamicCells[entity.cellIndex].AddEntity(entity);
                    dynamicCells[entity.oldCellIndex].RemoveEntity(entity);
                }
                else
                {
                    dynamicCells[entity.cellIndex].members = new List <MarauderEngine.Entity.Entity>();
                    ChangeCell(entity);
                }
            }
        }
        /// <summary>
        /// Changes cell property from one cell to another
        /// </summary>
        /// <param name="entity"></param>
        public void ChangeCell(MarauderEngine.Entity.Entity entity)
        {
            //Console.WriteLine("changing cell");

            if (EntityWithinBounds(entity.cellIndex))
            {
                if (dynamicCells[entity.cellIndex].members != null)
                {
                    dynamicCells[entity.oldCellIndex].RemoveEntity(entity);

                    int i = PositionToIndex(entity);
                    if (i >= 0 && i < cellLength)
                    {
                        dynamicCells[PositionToIndex(entity)].AddEntity(entity);
                    }
                }
                else
                {
                    dynamicCells[entity.cellIndex].members = new List <MarauderEngine.Entity.Entity>();
                    ChangeCell(entity);
                }
            }
        }
Example #16
0
 public IState Update(MarauderEngine.Entity.Entity entity)
 {
     return(null);
 }
 // adds entity to appropriate static cell
 public void AddStaticEntity(MarauderEngine.Entity.Entity entity)
 {
     entity.SetPartitionCell(PositionToCell(entity).X, PositionToCell(entity).Y);
     entity.SetCellIndex(PositionToIndex(entity));
     staticCells[entity.cellIndex].AddEntity(entity);
 }
Example #18
0
 /// <summary>
 /// The Exit State
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public IState ExitState(MarauderEngine.Entity.Entity entity)
 {
     // found something to do move to
     return(new GoTo());
 }
Example #19
0
 public IState ExitState(MarauderEngine.Entity.Entity entity)
 {
     throw new NotImplementedException();
 }
Example #20
0
 public void SetFocus(MarauderEngine.Entity.Entity entity)
 {
     focusedEntity = entity;
 }
Example #21
0
 public TriggerColliderComponent(MarauderEngine.Entity.Entity entity)
 {
     RegisterComponent(entity, "TriggerColliderComponent");
 }
Example #22
0
 /// <summary>
 /// Please provide the Entity that the state is being applied to
 /// </summary>
 /// <param name="entity">The Entity</param>
 /// <param name="initialState">The Initial State (Usually Idle)</param>
 public FSM(MarauderEngine.Entity.Entity entity, IState initialState)
 {
     _state = initialState.EnterState(entity);
 }
 public void RegisterComponent(MarauderEngine.Entity.Entity entity, string componentName)
 {
     Owner  = entity;
     Name   = componentName;
     Active = true;
 }
Example #24
0
 public override void Use(MarauderEngine.Entity.Entity entity)
 {
     //Console.WriteLine("fired Weapon");
 }
Example #25
0
 public PhysicsComponent(MarauderEngine.Entity.Entity owner, float colliderRadius)
 {
     RegisterComponent(owner, "PhysicsComponent");
     _data.Radius = colliderRadius;
     Active       = true;
 }
 // changes vector to to a 1D array index
 public int PositionToIndex(MarauderEngine.Entity.Entity entity)
 {
     return(PositionToCell(entity).X *numCellsX + PositionToCell(entity).Y);
 }
 public void LoadEntity(MarauderEngine.Entity.Entity entity)
 {
     dynamicCells[PositionToIndex(entity)].AddEntity(entity);
 }
Example #28
0
 public InputComponent(MarauderEngine.Entity.Entity entity)
 {
     RegisterComponent(entity, "InputComponent");
 }
Example #29
0
 public bool FireGlobalEvent(Event _event, MarauderEngine.Entity.Entity entity)
 {
     return(false);
 }
Example #30
0
 /// <summary>
 /// Adds entity to dynamic cell partition
 /// </summary>
 /// <param name="entity"></param>
 public void AddDynamicEntity(MarauderEngine.Entity.Entity entity)
 {
     cellSpacePartition.AddDynamicEntity(entity);
 }