Example #1
0
        public ServerShipManager(World serverWorld, EventManager eventManager, YmfasServer _server)
        {
            serverShipLog = Mogre.LogManager.Singleton.CreateLog("server-ship.log");
            serverShipLog.LogMessage("creating ssm");

            world = serverWorld;
            eventMgr = eventManager;
            server = _server;

            //init ships
            ShipTypeData curShipType = new ShipTypeData();
            curShipType.Class = ShipClass.Interceptor;
            curShipType.Model = ShipModel.MogreFighter;

            //player ships
            foreach (int id in server.PlayerIds )
            {
                Vector3 curPosition = Vector3.ZERO;//new Vector3(Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f), Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f), Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f));
                Quaternion curOrientation = Quaternion.IDENTITY;

                ShipInit curShipInit = new ShipInit(id, curShipType, curPosition, curOrientation,
                    server.GetPlayerName(id));
                eventMgr.SendEvent(curShipInit);

                Util.Log("sent init for ship " + id);

                //put them in world
                Ship s = new Ship(world, id, curPosition, curOrientation);
                shipTable.Add(id, s);
            }

            //init listeners
            ShipControlStatus.FiringEvent += new GameEventFiringHandler(handleShipControlStatus);
        }
Example #2
0
        public Missile(World _w, int _id, Vector3 _position, Quaternion _orientation, Ship _target)
        {
            id = _id;
            target = _target;

            MogreNewt.CollisionPrimitives.Box bodyBox =
                new MogreNewt.CollisionPrimitives.Box(_w, new Vector3(1.0f, 1.0f, 1.0f));
            body = new Body(_w, bodyBox);

            float mass;
            Vector3 inertia;
            body.getMassMatrix(out mass, out inertia);

               	body.setMassMatrix(1.0f, new Vector3(1.0f, 1.0f, 1.0f));

            body.setPositionOrientation(_position, _orientation);
            body.IsGravityEnabled = false;
            body.ForceCallback += new ForceCallbackHandler(ForceTorqueCallback);
            body.setAutoFreeze(0);
            body.setLinearDamping(0.0f);
            body.setAngularDamping(new Vector3(0.0f));
        }