コード例 #1
0
ファイル: CampModel.cs プロジェクト: svukelic/MinionWars
        public CampModel(Camp camp, int id)
        {
            this.id   = camp.id;
            this.name = camp.name;
            this.lat  = camp.location.Latitude.Value;
            this.lon  = camp.location.Longitude.Value;
            if (camp.owner_id != null)
            {
                this.owner_id = camp.owner_id.Value;
            }
            else
            {
                this.owner_id = -1;
            }

            List <Reputation> repl = OwnershipManager.GetUserCampReputation(id, camp.id);

            if (repl.Count == 0)
            {
                this.reputation = 0;
            }
            else
            {
                this.reputation = repl.First().value.Value;
            }
        }
コード例 #2
0
        public ActionResult UpdateDelete(OwnershipViewModel OSPViewModel, string command)
        {
            string PageAction = "";
            bool   result     = false;

            user = (UserSession)Session["User"];

            if (command == "Save")
            {
                OwnershipManager OSPManager = new OwnershipManager();
                result     = OSPManager.UpdateOwnership(OSPViewModel);
                PageAction = "UPDATE";
            }
            else if (command == "Delete")
            {
                OwnershipManager OSPManager = new OwnershipManager();
                result     = OSPManager.DeleteOwnership(OSPViewModel);
                PageAction = "DELETE";
            }
            if (result)
            {
                TempData["SuccessMessage"] = PageAction + " successful";
                new AuditLogManager().Audit(user.Username, DateTime.Now, "Ownership", PageAction, OSPViewModel.Id, OSPViewModel.OWNSHP);
            }
            else
            {
                TempData["ErrorMessage"] = PageAction + " failed";
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        // GET: Ownership
        public ActionResult Index()
        {
            // Validate log in and user access
            UserAccessSession UASession = (UserAccessSession)Session["UserAccess"];

            // OWN -> Ownership
            // Refer to UserAccessSession
            if (UASession == null || !UASession.OWN)
            {
                return(RedirectToAction("Login", "Account"));
            }

            user = (UserSession)Session["User"];
            Session["CurrentPage"] = new CurrentPageSession("OWN", "HOME", "LOG");

            // Get all data stored in DB table
            OwnershipManager   OSPManager   = new OwnershipManager();
            OwnershipViewModel OSPViewModel = new OwnershipViewModel();

            OSPViewModel.OHPList = OSPManager.GetOSP();
            if (OSPViewModel.OHPList == null || OSPViewModel.OHPList.Count() == 0)
            {
                OSPViewModel.OHPList = new List <OwnershipViewModel>();
            }
            // return View with ViewModel
            return(View(OSPViewModel));
        }
コード例 #4
0
ファイル: UserDataModel.cs プロジェクト: svukelic/MinionWars
        public UserDataModel(int id)
        {
            this.userModel = UsersManager.GetUserData(id);

            minions = new List <MinionModel>();
            List <MinionOwnership> ownership = OwnershipManager.GetOwnershipData(id);

            foreach (MinionOwnership mo in ownership)
            {
                Minion      m  = OwnershipManager.GetMinionsData(mo.minion_id);
                MinionType  mt = OwnershipManager.GetTypeData(m.mtype_id);
                MinionModel mm = new MinionModel(m, mo, mt, null);

                minions.Add(mm);
            }

            if (userModel.personal_bg_id != null)
            {
                personalBg = new BattlegroupModel(userModel.personal_bg_id.Value);
            }
            else
            {
                userModel.personal_bg_id = -1;
            }

            this.remoteBgs = new List <BattlegroupModel>();
            List <Battlegroup> remote_bgs = OwnershipManager.GetRemoteBattlegroups(userModel.id, userModel.personal_bg_id.Value);

            foreach (Battlegroup b in remote_bgs)
            {
                remoteBgs.Add(new BattlegroupModel(b.id));
            }

            this.treasury = new List <TreasuryModel>();
            List <UserTreasury> ut = ResourceManager.GetUserTreasury(userModel.id);

            foreach (UserTreasury u in ut)
            {
                TreasuryModel tm = new TreasuryModel(u.ResourceType.name, u.amount.Value, u.ResourceType.category);
                this.treasury.Add(tm);
            }

            this.personalCamps = OwnershipManager.GetUserCamps(id);

            this.reputation = new List <ReputationModel>();
            List <Reputation> repList = OwnershipManager.GetUserReputation(id);

            foreach (Reputation r in repList)
            {
                Camp            c  = CampManager.GetCampInfo(r.camp_id);
                ReputationModel rm = new ReputationModel(c, r);
                this.reputation.Add(rm);
            }

            this.buildings = CampManager.GetAllBuildings();
        }
        /// <summary>
        /// Main entry point for he business logic that the plug-in is to execute.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics 365 caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new InvalidPluginExecutionException("localContext");
            }

            // Assign record automatically to an owner team
            OwnershipManager manager = new OwnershipManager(localContext.OrganizationService, localContext.PluginExecutionContext, null);

            manager.SetOwner();
        }
コード例 #6
0
        public BattlegroupModel(int id)
        {
            this.battlegroup   = OwnershipManager.GetBattlegroupData(id);
            this.minions       = new List <MinionModel>();
            this.currentAmount = 0;

            List <BattlegroupAssignment> bga = OwnershipManager.GetAssignmentData(id);

            foreach (BattlegroupAssignment a in bga)
            {
                Minion     m  = OwnershipManager.GetMinionsData(a.minion_id);
                MinionType mt = OwnershipManager.GetTypeData(m.mtype_id);
                this.minions.Add(new MinionModel(m, null, mt, a));
                this.currentAmount += a.group_count;
            }
        }
コード例 #7
0
    public override void OnServerAddPlayer(NetworkConnection conn)
    {
        _ownershipManager = GameObject.Find("ServerManager").GetComponent <OwnershipManager>();
        Transform  playerSpawnPoint = numPlayers == 0 ? WhitePlayerSpawnPoint : BlackPlayerSpawnPoint;
        GameObject player           = Instantiate(playerPrefab, playerSpawnPoint.position, playerSpawnPoint.rotation);

        NetworkServer.AddPlayerForConnection(conn, player);

        _ownershipManager.SetPieceAuthority(conn, numPlayers == 1 ? Assets._Scripts.Pieces.Enums.PieceColor.White : Assets._Scripts.Pieces.Enums.PieceColor.Black);


        if (numPlayers == MaximumAmountOfPlayers)
        {
            //TODO start game
        }
        else
        {
            NetworkPlayersHelper.UpdateGameStatusForConnectedPlayers($"Waiting for {MaximumAmountOfPlayers - numPlayers} more player to join.");
        }
    }
コード例 #8
0
        public ActionResult AddMinionsToGroup(int?o_id, int?amount, int?line, int?bg_id, string name)
        {
            string result = OwnershipManager.ProcessAddition(o_id, amount, line, bg_id, name);

            return(Json(result));
        }