Пример #1
0
    // Use this for initialization
    void Start()
    {
        //Factory<OrbAction> factory = new Factory<OrbAction>();
        //factory.Rigister(1, typeof(OrbAction));

        //OrbAction ac = factory.Create(1);
        //Debug.LogError("1111");
        SkillFactory.RigisterSkill();
        OrbData orbData = new OrbData()
        {
            name = "Test Orb"
        };

        //
        List <OrbActionData> createAc = new List <OrbActionData>();

        createAc.Add(new Ac_LogData()
        {
            id = 1, type = 1, name = "", content = "Orb create"
        });
        orbData.createActions = createAc.ToArray();
        //
        List <OrbMotionData> motions = new List <OrbMotionData>();

        motions.Add(new Mo_MoveDirData()
        {
            type = 1, name = "", speed = 10, dir = Vector3.forward
        });
        orbData.motions = motions.ToArray();
        //
        orb = Orb.Instantiate(null, null, null, orbData);
    }
Пример #2
0
    public OrbData SwapOrbs(OrbData orb)
    {
        OrbData returnOrb = _currentOrb;

        _currentOrb = orb;
        UpdateOrb();
        OnOrbChanged.Invoke();
        return(returnOrb);
    }
Пример #3
0
    static void ReadMessagesSyncRequest()
    {
        beingReadSyncRequest        = incomingSyncRequestMessages;
        incomingSyncRequestMessages = new List <string>();

        foreach (string request in beingReadSyncRequest)
        {
            Debug.Log("Generating Sync Data");

            //Create the message string
            string message = "3|";

            var currentIds = objectManager.currentOrbs.Keys.ToArray(); //To array is used in case the source needs to be modified
            int counter    = 0;

            foreach (long Id in currentIds)
            {
                //Limit the number of orbs in game to 1000, because the message size otherwise might get huge; also make sure the message fits in our buffer
                if (counter >= 5000 || message.Length > 149950)
                {
                    break;
                }

                OrbData current = objectManager.currentOrbs[Id];
                message += current.XPos + ":";
                message += current.YPos + ":";
                message += current.Id + "?";
                counter++;
            }

            //Remove the trailing '?'
            message = message.Trim('?');


            //Send the message to the server
            if (counter >= 5000 || message.Length > 149950)
            {
                netComs.NBSendMessage(50, message);
            }
            else
            {
                netComs.NBSendMessage(2, message);
            }
        }
    }
        public void Save(GameStateManager gsm)
        {
            TileManager tileManager = TileManager.Instance;
            int         width       = tileManager.width;
            int         height      = tileManager.height;
            MapLoader   mapLoader   = gsm.mapLoader;

            MapData mapData = new MapData();

            mapData.name = editorUIManager.editInfoNameField.text;
            // mapData.comment = editorUIManager.editInfoDescriptionText.text;
            mapData.winCondition = gsm.mapData.winCondition;
            mapData.width        = width;
            mapData.height       = height;
            mapData.tiles        = new char[width * height];
            for (int i = 0; i < width * height; i++)
            {
                int x = i % width;
                int y = height - i / width - 1;
                mapData.tiles[i] = tileDataDict[tileManager.tiles[x, y].Data];
            }
            mapData.background          = gsm.mapData.background;
            mapData.playerData          = new PlayerData();
            mapData.playerData.position = gsm.player.pos.GetVector2i();
            mapData.monsters            = gsm.monsters.Select(m =>
            {
                MonsterData data = new MonsterData();
                data.name        = m.name.Replace("(Clone)", "");
                data.position    = m.pos.GetVector2i();
                return(data);
            }).ToArray();
            mapData.orbs = gsm.orbs.Select(o =>
            {
                OrbData data  = new OrbData();
                data.color    = colorDict[o.Color];
                data.position = o.pos.GetVector2i();
                return(data);
            }).ToArray();
            mapData.buttons = gsm.buttons.Select(b =>
            {
                ButtonData data = new ButtonData();
                data.name       = b.name.Replace("(Clone)", "");
                data.position   = b.pos.GetVector2i();
                if (b is WallToggleButton)
                {
                    var wtButton           = (WallToggleButton)b;
                    data.togglePosition    = wtButton.wallTogglePos;
                    data.isWallOnButtonOff = wtButton.isWallOnButtonOff;
                }
                if (b is WallToggleLever)
                {
                    var wtLever            = (WallToggleLever)b;
                    data.togglePosition    = wtLever.wallTogglePos;
                    data.isWallOnButtonOff = wtLever.isWallOnButtonOff;
                }
                return(data);
            }).ToArray();

            string jsonData = JsonHelper.Serialize <MapData>(mapData);

            System.IO.File.WriteAllText(Application.dataPath + "/Maps/" + mapData.name + ".json", jsonData);
        }
 public void ResetOrbs()
 {
     currentOrb = noOrb;
 }
Пример #6
0
 public bool ContainOrb(OrbData orb)
 {
     return(_currentOrb == orb);
 }