public async Task <ActionResult> New(MobModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ErrorMessages = ModelState.SelectMany(x => x.Value.Errors.Select(y => y.ErrorMessage));
                return(View(model));
            }

            var result = await _mobLogic.AddMob(model.Name, User.Identity.Name);

            if (result.Count() > 0)
            {
                ViewBag.ErrorMessages = result;
                return(View());
            }

            return(RedirectToAction("Edit", model.Name));
        }
Exemple #2
0
        public SpawnsManager()
        {
            string modelsJson = File.ReadAllText("data/mobModels.json");

            foreach (var item in JsonConvert.DeserializeObject <MobModel[]>(modelsJson))
            {
                mobModels.Add(item.id, item);
            }

            string portalsJson = File.ReadAllText("data/portals.json");

            foreach (var item in JsonConvert.DeserializeObject <PortalData[]>(portalsJson))
            {
                Portal go = GameObject.Instantiate <Portal>(item.x, item.y);
                go.BaseId = 2;
                go.mapId  = item.map;
                go.map    = item.targetMap;
                go.spawnX = item.spawnX;
                go.spawnY = item.spawnY;

                MapsManager.GetMap(item.map, out Map m);
                m.AddPlayer(go.ObjectId);
            }

            string json = File.ReadAllText("data/spawns.json");

            foreach (var item in JsonConvert.DeserializeObject <SpawnData[]>(json))
            {
                GameObject go = GameObject.Instantiate <Character>(item.x, item.y, item);
                go.BaseId      = item.id;
                go.mapId       = item.map;
                go.respawnable = true;
                go.respawnTime = item.time;
                MobModel model = mobModels[go.BaseId];
                go.stats[Stat.LVL]        = model.lvl;
                go.stats[Stat.MAX_HEALTH] = model.health;
                go.stats[Stat.HEALTH]     = model.health;
                go.stats[Stat.DAMAGE]     = model.damage;

                MapsManager.GetMap(item.map, out Map m);
                m.AddPlayer(go.ObjectId);
            }
        }
Exemple #3
0
    void Awake()
    {
#if UNITY_EDITOR
        Log.level = Log.LogLevel.DEBUG;
#else
        Log.level = Log.LogLevel.INFO;
#endif
        Debug.Log("---------------  Awake ------------------------");
        Transform facadeContainer = this.transform.Find("facades");
        facades = new UIFacade[facadeContainer.childCount];
        for (int i = 0; i < facadeContainer.childCount; i++)
        {
            Transform child = facadeContainer.GetChild(i);
            facades[i] = child.GetComponent <UIFacade>();
            facades[i].Register();
        }

        initialize();

        playerModel_ = new PlayerModel();
        PlayerView       playerView       = new PlayerView();
        PlayerController playerController = new PlayerController();
        framework.modelCenter.Register(PlayerModel.NAME, playerModel_);
        framework.viewCenter.Register(PlayerView.NAME, playerView);
        framework.controllerCenter.Register(PlayerController.NAME, playerController);

        mobModel_ = new MobModel();
        MobView       mobView       = new MobView();
        MobController mobController = new MobController();
        framework.modelCenter.Register(MobModel.NAME, mobModel_);
        framework.viewCenter.Register(MobView.NAME, mobView);
        framework.controllerCenter.Register(MobController.NAME, mobController);

        inputController_ = new InputController();
        framework.controllerCenter.Register(InputController.NAME, inputController_);
    }