Example #1
0
        //public List<GameObject> Contacts;

        //public Described PickingTarget;

        //public List<DescribedProfile> Inventory;
        //ItemSword _Sword;
        //Entity SwordEntity;
        //public CharacterAnimBlender AnimBlender;


        //public bool TalkPerm;
        //public bool InventoryPerm;

        //public bool PickItemOrder;
        //public bool MoveOrder;
        //public bool MoveOrderBack;

        //public bool GetSwordOrder;
        //public bool HideSwordOrder;
        //bool _RunOrder;

        /*public bool RunOrder
         * {
         *  get
         *  {
         *      return _RunOrder;
         *  }
         *  set
         *  {
         *      if (_RunOrder == true && value == false)
         *      {
         *          _RunOrder = false;
         *          Profile.WalkSpeed -= 2.0f;
         *      }
         *      if (_RunOrder == false && value == true)
         *      {
         *          _RunOrder = true;
         *          Profile.WalkSpeed += 2.0f;
         *      }
         *  }
         * }
         *
         * public float TurnDelta;
         *
         * public bool FollowPathOrder;
         * public List<Vector3> WalkPath;
         * public static DecTree.Enemies.e_Node Tree = new EnemyDecTree();
         *
         *
         * //////////////////////////////////////////////
         * //              Moje zmienne:
         * //////////////////////////////////////////////
         *
         * Container Container;
         * public bool isContainer;
         * bool isSeen;
         * bool isReachable;
         * float ZasiegWzroku;
         * float ZasiegOgolny;
         * Prize DropPrize;
         * public Statistics Statistics;*/

        public Enemy(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            // Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia * Profile.BodyMass);
            //Body.AutoSleep = false;

            //Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            //Joint upVector = new MogreNewt.BasicJoints.UpVector(
            // Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
Example #2
0
        //public List<GameObject> Contacts;
        //public Described PickingTarget;
        //public List<DescribedProfile> Inventory;
        //ItemSword _Sword;
        //Entity SwordEntity;
        //public CharacterAnimBlender AnimBlender;
        //public bool TalkPerm;
        //public bool InventoryPerm;
        //public bool PickItemOrder;
        //public bool MoveOrder;
        //public bool MoveOrderBack;
        //public bool GetSwordOrder;
        //public bool HideSwordOrder;
        //bool _RunOrder;
        /*public bool RunOrder
        {
            get
            {
                return _RunOrder;
            }
            set
            {
                if (_RunOrder == true && value == false)
                {
                    _RunOrder = false;
                    Profile.WalkSpeed -= 2.0f;
                }
                if (_RunOrder == false && value == true)
                {
                    _RunOrder = true;
                    Profile.WalkSpeed += 2.0f;
                }
            }
        }

        public float TurnDelta;

        public bool FollowPathOrder;
        public List<Vector3> WalkPath;
        public static DecTree.Enemies.e_Node Tree = new EnemyDecTree();

        //////////////////////////////////////////////
        //              Moje zmienne:
        //////////////////////////////////////////////

        Container Container;
        public bool isContainer;
        bool isSeen;
        bool isReachable;
        float ZasiegWzroku;
        float ZasiegOgolny;
        Prize DropPrize;
        public Statistics Statistics;*/
        public Enemy(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            // Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia * Profile.BodyMass);
            //Body.AutoSleep = false;

            //Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            //Joint upVector = new MogreNewt.BasicJoints.UpVector(
            // Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }