Ejemplo n.º 1
0
        public Cell(CellSystem system, int id, UnityEngine.Vector3 pos, UnityEngine.Vector2 dim, UnityEngine.Vector2 h)
        {
            Position      = pos;
            Dimensions    = dim;
            Heights       = h;
            ID            = id;
            CellSystemRef = new WeakReference(system);
            PlayerSpawn   = false;

            Debugger.Log("Created cell at position " + Position + " and dimensions " + Dimensions);
        }
Ejemplo n.º 2
0
        public override void Initialise(BloodAndBileEngine.WorldState.WorldState worldState)
        {
            WorldStateWeakRef.Target = worldState;
            WorldState.CellSystem cellSystem = worldState.GetData <WorldState.CellSystem>();
            if (cellSystem != null)
            {
                CellSystemWeakRef.Target = cellSystem;
            }
            else
            {
                CellSystemWeakRef.Target = null;
            }

            CurrentSpeed = BaseSpeed;
        }
Ejemplo n.º 3
0
    public StateUpdateObject[] GetStateUpdateInformation()
    {
        List <StateUpdateObject> stateUpdates = new List <BloodAndBileEngine.Networking.Messaging.NetworkMessages.StateUpdateObject>();

        // STATE UPDATE DU WORLDSTATE

        List <object> EntityPositions = new List <object>();

        BloodAndBileEngine.WorldState.CellSystem worldCellSystem = CurrentWorldState.GetData <BloodAndBileEngine.WorldState.CellSystem>();

        foreach (BloodAndBileEngine.WorldState.Cell cell in worldCellSystem.GetCells())
        {
            foreach (BloodAndBileEngine.Entity entity in cell.GetEntities())
            {
                EntityPositions.Add(entity.ID);
                EntityPositions.Add(entity.Position);
            }
        }
        //
        return(stateUpdates.ToArray());
    }
Ejemplo n.º 4
0
    public static Match CreateMatch(int[] players)
    {
        Match m = new Match();

        m.SetPlayerConnectionIDs(players);
        m.AddModule <MapStateModule>(new MapStateModule(m));       // Création du World State lié au match
        m.AddModule <EntitiesManagerModule>(new EntitiesManagerModule(m));
        m.AddModule <StateUpdateModule>(new StateUpdateModule(m)); // Création du module StateUpdate
        m.AddModule <MatchOutcomeManagerModule>(new MatchOutcomeManagerModule(m));

        // Création du WorldState initial.

        BloodAndBileEngine.WorldState.WorldState startWorldState = m.GetModule <MapStateModule>().GetWorldState();
        // Objectif : initialise le startWorldState en fonction des informations dont on dispose.

        // INITIALISER TOUS LES WorldStateData ici !


        // Ajout du EntityFactory
        BloodAndBileEngine.WorldState.WorldStateData.WorldEntityFactory factory = new BloodAndBileEngine.WorldState.WorldStateData.WorldEntityFactory(startWorldState);
        startWorldState.AddData(factory);

        // Initialisation des cellules.

        if (BloodAndBileEngine.WorldState.Map.Maps == null)
        {
            BloodAndBileEngine.WorldState.Map.LoadMaps();
        }
        BloodAndBileEngine.WorldState.Map map = BloodAndBileEngine.WorldState.Map.Maps[UnityEngine.Random.Range(0, BloodAndBileEngine.WorldState.Map.Maps.Count)];

        // Création du CellSystem.

        BloodAndBileEngine.WorldState.CellSystem cellSystem;
        cellSystem = new BloodAndBileEngine.WorldState.CellSystem(map);
        startWorldState.AddData <BloodAndBileEngine.WorldState.CellSystem>(cellSystem);
        startWorldState.AddData <BloodAndBileEngine.WorldState.Map>(map);


        return(m);
    }