예제 #1
0
 public static void SaveTarget(Camp camp, Transform target)
 {
     Debug.Log($"set {camp} target:{target?.name ?? "null"}");
     if (camp == Camp.Player)
     {
         PlayerTarget = target;
     }
     else if (camp == Camp.Enemy)
     {
         EnemyTarget = target;
     }
 }
예제 #2
0
    public Camp CreateCamp()
    {
        var pos = (campPos + Global.UnitSizeVec);

        camp = GameObject.Instantiate(CampPrefab, transform.position + (Vector3)pos, Quaternion.identity,
                                      transParentItem.parent)
               .GetComponent <Camp>();
        camp.pos    = pos;
        camp.size   = Global.UnitSizeVec;
        camp.radius = camp.size.magnitude;
        return(camp);
    }
예제 #3
0
        public static bool DestroyCamp(int id)
        {
            using (var db = new MinionWarsEntities())
            {
                Camp camp = db.Camp.Find(id);

                db.Camp.Remove(camp);
                db.SaveChanges();

                return(true);
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Name,AgeFrom,AgeTo,CategoryId,IsAvailable")] Camp camp)
        {
            if (ModelState.IsValid)
            {
                _context.Add(camp);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", camp.CategoryId);
            return(View(camp));
        }
예제 #5
0
        public async Task <IActionResult> PostCamp([FromBody] Camp camp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Camps.Add(camp);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCamp", new { id = camp.CampId }, camp));
        }
        public Camp DeleteCamp(int CampID)
        {
            Camp dbEntry = context.Camps
                           .FirstOrDefault(b => b.Id == CampID);

            if (dbEntry != null)
            {
                context.Camps.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
예제 #7
0
 public void CreateSimpleCamp()
 {
     var beginTime = DateTime.Now.AddDays(-20);
     var endTime = DateTime.Now.AddDays(-18);
     var displayBegin = DateTime.Now.AddDays(-40);
     var displayEnd = DateTime.Now.AddDays(-5);
     var c = new Camp(CampType.Junior, beginTime, endTime,
                      displayBegin, displayEnd,
                      "Description", "http://www.lejr.dk");
     
     Assert.DoesNotThrow(c.Create);
 }
예제 #8
0
    public void init(Camp camp, Overlord ol)
    {
        this.camp     = camp;
        this.overlord = ol;

        stats        = new EntityStats();
        stats.attack = 10000;
        cSlice       = this.gameObject.AddComponent <CombatSlice>();
        //cSlice = new CombatSlice();
        cSlice.init(stats, this, null, null);
        active = true;
    }
예제 #9
0
 //Get the details of a particular employee
 public Camp GetCampData(int id)
 {
     try
     {
         Camp Camp = db.Camp.Find(id);
         return(Camp);
     }
     catch
     {
         throw;
     }
 }
예제 #10
0
 //To Update the records of a particluar employee
 public void UpdateCamp(Camp Camp)
 {
     try
     {
         db.Entry(Camp).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #11
0
 //To Add new Camp record
 public void AddCamp(Camp Camp)
 {
     try
     {
         db.Camp.Add(Camp);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #12
0
 public static Transform GetTarget(Camp camp)
 {
     if (camp == Camp.Player)
     {
         return(PlayerTarget);
     }
     if (camp == Camp.Enemy)
     {
         return(EnemyTarget);
     }
     return(null);
 }
예제 #13
0
 // 更新
 public override void Update()
 {
     // 兵營執行命令
     foreach (SoldierCamp Camp in m_SoldierCamps.Values)
     {
         Camp.RunCommand();
     }
     foreach (CaptiveCamp Camp in m_CaptiveCamps.Values)
     {
         Camp.RunCommand();
     }
 }
예제 #14
0
        public async Task <IHttpActionResult> Post(string moniker, TalkDto talkDto)
        {
            try
            {
                if (await _repository.GetTalkByMonikerAsync(moniker, talkDto.TalkId) != null)
                {
                    ModelState.AddModelError("TalkId", "TalkId is already in use inside this camp..!");                     // optional because EF generates a new id every time. The id inside the body won't be used...
                }

                if (ModelState.IsValid)
                {
                    Talk talk = _mapper.Map <Talk>(talkDto);

                    // Map the camp to the talk (camp is here a foreign key for the Talk class/model and it's not a part of the TalkDto)...
                    Camp camp = await _repository.GetCampAsync(moniker);

                    if (camp == null)
                    {
                        return(BadRequest("No camp found for this moniker..!"));
                    }
                    talk.Camp = camp;

                    // If a SpeakerId is given, map the speaker to the talk...
                    if (talkDto.Speaker != null)
                    {
                        Speaker speaker = await _repository.GetSpeakerAsync(talkDto.Speaker.SpeakerId);

                        if (speaker == null)
                        {
                            return(BadRequest("No speaker found with this Id..!"));
                        }
                        talk.Speaker = speaker;                                                                             // append the speaker data for the given id to the talk to be created...
                    }

                    _repository.AddTalk(talk);

                    if (await _repository.SaveChangesAsync())
                    {
                        TalkDto newTalk = _mapper.Map <TalkDto>(talk);

                        return(Created(new Uri(Request.RequestUri + "/" + newTalk.TalkId), newTalk));
                        //return CreatedAtRoute("GetTalk", new { moniker = moniker, talkId = talk.TalkId }, newTalk);       // TODO: Exception "UrlHelper.Link must not return null".   But why???
                    }
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(BadRequest(ModelState));
        }
예제 #15
0
        private void SaveCamps(XmlWriter writer, Camp camp, string[] enemies)
        {
            writer.WriteStartElement(CAMP);

            //m_name;//resource
            writer.WriteStartElement(NAME);
            writer.WriteValue(camp.Name);
            writer.WriteEndElement();

            //m_campType;//CampType
            writer.WriteStartElement(CAMP_TYPE);
            writer.WriteValue(camp.CampType.ToString());
            writer.WriteEndElement();

            //m_winTime;//CampWinTime or integer
            writer.WriteStartElement(WIN_TIME);
            writer.WriteValue(camp.WinTime.ToString());
            writer.WriteEndElement();

            //m_sectorId;//integer
            writer.WriteStartElement(SECTOR);
            writer.WriteValue(camp.SectorId);
            writer.WriteEndElement();

            //m_left;//double
            if (camp.Left > 0)
            {
                writer.WriteStartElement(LEFT);
                writer.WriteValue(camp.Left.ToString(CultureInfo.InvariantCulture));
                writer.WriteEndElement();
            }

            //m_top;//double
            if (camp.Top > 0)
            {
                writer.WriteStartElement(TOP);
                writer.WriteValue(camp.Top.ToString(CultureInfo.InvariantCulture));
                writer.WriteEndElement();
            }

            //unit(convert to EnemyUnit), count
            //m_counts;
            foreach (KeyValuePair <short, short> pair in camp.Counts)
            {
                writer.WriteStartElement(ENEMY);
                writer.WriteAttributeString(UNIT, m_units[pair.Key].Id);
                writer.WriteAttributeString(COUNT, pair.Value.ToString(CultureInfo.InvariantCulture));
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
예제 #16
0
        public static List <Camp> InitiateDiscovery(DbGeography loc, string locType)
        {
            string             places   = GetPlaces(loc.Latitude.Value, loc.Longitude.Value, 1000, locType).Result;
            List <Camp>        newCamps = new List <Camp>();
            List <DbGeography> newLocs  = new List <DbGeography>();
            //parse, create new camp
            dynamic obj = JsonConvert.DeserializeObject(places);

            //dynamic obj = JObject.Parse(places);
            if (obj["results"] != null)
            {
                for (int i = 0; i < obj["results"].Count; i++)
                {
                    dynamic     place  = obj["results"][i];
                    var         point  = string.Format("POINT({1} {0})", place["geometry"]["location"]["lat"], place["geometry"]["location"]["lng"]);
                    DbGeography newLoc = DbGeography.FromText(point);
                    newLocs.Add(newLoc);
                }
            }

            string name = "";

            if (locType.Equals("restaurant"))
            {
                name = "Neutral Camp";
            }
            else if (locType.Equals("gas_station"))
            {
                name = "Message Board";
            }
            else if (locType.Equals("bank"))
            {
                name = "Neutral Trader";
            }

            using (var db = new MinionWarsEntities())
            {
                foreach (DbGeography l in newLocs)
                {
                    Console.WriteLine("Discovery found: " + name);
                    List <Camp> check = new List <Camp>();
                    check = db.Camp.Where(x => x.location.Distance(l) <= 250).ToList();
                    if (check.Count == 0)
                    {
                        Camp nc = CampManager.CreateCamp(-1, l, name);
                        newCamps.Add(nc);
                    }
                }
            }

            return(newCamps);
        }
예제 #17
0
파일: Room.cs 프로젝트: Hengle/GameDemo
    public RoomPlayer GetRoomPlayer(Camp camp)
    {
        for (int i = 0; i < roomPlayerList.Count; ++i)
        {
            RoomPlayer roomPlayer = roomPlayerList[i];
            if (roomPlayer.Camp == camp)
            {
                return(roomPlayer);
            }
        }

        return(null);
    }
예제 #18
0
 public void ClearCache()
 {
     m_CachedPosition  = null;
     m_CachedMovement  = null;
     m_CachedModel     = null;
     m_CachedAbility   = null;
     m_CachedCollider  = null;
     m_CachedProperty  = null;
     m_CachedModifier  = null;
     m_CachedClickable = null;
     m_CachedTracker   = null;
     m_CachedCamp      = null;
 }
예제 #19
0
        public async Task <ActionResult> Delete(Camp camp)
        {
            try
            {
                await _campService.DeleteAsync(camp);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
예제 #20
0
        public ActionResult Create([Bind(Include = "CampsID,Name,Address1,PlaceID,DistrictID")] Camp camp)
        {
            if (ModelState.IsValid)
            {
                db.Camps.Add(camp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "Name", camp.DistrictID);
            ViewBag.PlaceID    = new SelectList(db.Places, "PlaceID", "Name", camp.PlaceID);
            return(View(camp));
        }
예제 #21
0
 //To Delete the record of a particular employee
 public void DeleteCamp(int id)
 {
     try
     {
         Camp emp = db.Camp.Find(id);
         db.Camp.Remove(emp);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
예제 #22
0
        public void AddMemberToCamp(int campId, int memberId)
        {
            Camp dbEntry = context.Camps
                           .FirstOrDefault(c => c.Id == campId);

            if (dbEntry != null)
            {
                dbEntry.Members.Add(new Members.Member {
                    Id = memberId
                });
                context.SaveChanges();
            }
        }
예제 #23
0
 public void Setup()
 {
     _instructor = Build.Instructor().WithMoney(100).Item;
     _student    = Build.Student().WithMoney(100).Item;
     _student2   = Build.Student().WithMoney(100).Item;
     _camp       = Build.Camp()
                   .WithMoney(5000)
                   .WithDefaultSlotPrice(20)
                   .WithParticipant(_instructor)
                   .WithParticipant(_student)
                   .WithParticipant(_student2);
     _day = Build.Day().ForCamp(_camp);
 }
예제 #24
0
        public async Task <ActionResult <CampModel> > Get(string moniker)
        {
            try
            {
                Camp result = await this._campRepository.GetCampAsync(moniker);

                return(result != null?this._mapper.Map <CampModel>(result) : NotFound());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }
        }
예제 #25
0
    /*
    public void AssignCampRegion(MapRegion campRegion)
    {
        assignedCampRegion=campRegion;
        if (assignedCampRegion.hasCamp)
        {
            campShown=true;
            availableRecipes.Clear();
            availableRecipes=CraftRecipe.GetAllRecipes();

            GetComponent<Canvas>().enabled=true;
            RefreshSlots();
        }
        else CloseScreen();
    }*/
    public void RefreshSlots()
    {
        //Remove old cooking slot
        //Image oldCookingSlot=cookingSlotPlacement.GetComponentInChildren<Image>();
        //if (oldCookingSlot!=null) {GameObject.Destroy(oldCookingSlot.gameObject); print ("Old cooking slot deleted!");}
        // {print ("Old cooking slot not found!");}
        foreach (Image oldCookingSlot in cookingSlotPlacement.GetComponentsInChildren<Image>())//.GetComponentsInChildren<Button>())
        {
            //print ("Old cooking slot deleted!");
            GameObject.Destroy(oldCookingSlot.gameObject);
        }

        //Remove old bed slots
        foreach (Image oldBedSlot in bedSlotGroup.GetComponentsInChildren<Image>())//.GetComponentsInChildren<Button>())
        {
            GameObject.Destroy(oldBedSlot.gameObject);
        }

        //Remove old crafting recipes
        foreach (HorizontalLayoutGroup oldRecipeGroup in craftGroup.GetComponentsInChildren<HorizontalLayoutGroup>())
        {GameObject.Destroy(oldRecipeGroup.gameObject);}

        if (InventoryScreenHandler.mainISHandler.selectedMember.currentRegion.hasCamp)
        {
            campShown=true;
            availableRecipes.Clear();
            //Search local inventory and all present member inventories for tools
            bool partyHasTools=false;
            List<InventoryItem> sumLocalInventory=new List<InventoryItem>();
            sumLocalInventory.AddRange(InventoryScreenHandler.mainISHandler.selectedMember.currentRegion.GetStashedItems());
            foreach (PartyMember member in InventoryScreenHandler.mainISHandler.selectedMember.currentRegion.localPartyMembers)
            {
                sumLocalInventory.AddRange(member.carriedItems);
            }

            availableRecipes=CraftRecipe.GetGenericRecipes();
            GetComponent<Canvas>().enabled=true;

            assignedCamp=InventoryScreenHandler.mainISHandler.selectedMember.currentRegion.campInRegion;

            //Refresh crafting recipes
            foreach (CraftRecipe recipe in availableRecipes)
            {
                RecipeGroup newRecipeDisplay=Instantiate(recipePrefab);
                newRecipeDisplay.transform.SetParent(craftGroup);
                newRecipeDisplay.AssignRecipe(recipe);

            }
        }
        else CloseScreen();
    }
예제 #26
0
        public void OnClickDump()
        {
            string       path     = Application.dataPath + "/../SavedMap_" + System.DateTime.Now.ToBinary().ToString() + ".rc";
            BinaryWriter writer   = new BinaryWriter(new FileStream(path, FileMode.Create));
            Camp         bestCamp = GetComponent <SimulationController>().BestCamp;

            writer.Write(CalculateHappiness());
            // Player's camp
            writer.Write(tents.Count);
            foreach (GameObject tent in tents)
            {
                writer.Write((int)tent.transform.position.x);
                writer.Write((int)tent.transform.position.z);
            }

            writer.Write(watertanks.Count);
            foreach (GameObject watertank in watertanks)
            {
                writer.Write((int)watertank.transform.position.x);
                writer.Write((int)watertank.transform.position.z);
            }

            writer.Write(washrooms.Count);
            foreach (GameObject washroom in washrooms)
            {
                writer.Write((int)washroom.transform.position.x);
                writer.Write((int)washroom.transform.position.z);
            }
            // AI's camp
            writer.Write(bestCamp.GetHappiness());
            foreach (Tent tent in bestCamp.GetTents())
            {
                writer.Write(tent.X());
                writer.Write(tent.Y());
            }

            foreach (Water water in bestCamp.GetWaters())
            {
                writer.Write(water.X());
                writer.Write(water.Y());
            }

            foreach (Toilet toilet in bestCamp.GetToilets())
            {
                writer.Write(toilet.X());
                writer.Write(toilet.Y());
            }
            writer.Write(Settings.WaterHeight);
            writer.Close();
            Application.Quit();
        }
예제 #27
0
 /*Constructeur*/
 // On crée une action générique à partir d'un action, on réalise la conversion
 public GenericAction(Board board, Vector2Int context, Action ac, Camp camp)
 {
     this.oldPosition = new Vector2Int(ac.oldPosition.x - context.x, ac.oldPosition.y - context.y);
     this.newPosition = new Vector2Int(ac.newPosition.x - context.x, ac.newPosition.y - context.y);
     this.captured    = new HashSet <Capture>();
     type             = getTypePiece(board, ac.oldPosition);
     foreach (Vector2Int vec in ac.captured)
     {
         this.captured.Add(
             new Capture(new Vector2Int(vec.x - ac.oldPosition.x, vec.y - ac.oldPosition.y),
                         getTypePiece(board, vec)));
     }
     this.camp = camp;
 }
예제 #28
0
        // GET: Camps/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Camp camp = db.Camps.Find(id);

            if (camp == null)
            {
                return(HttpNotFound());
            }
            return(View(camp));
        }
예제 #29
0
    public new static Hall Load(BinaryReader reader)
    {
        HallType subType = (HallType)reader.ReadInt32();
        Hall     ret     = null;

        switch (subType)
        {
        case HallType.BASE:
            ret = Camp.Load(reader);
            break;
        }
        ret.subType = subType;
        return(ret);
    }
예제 #30
0
        // Перемещаем лагерь
        private void Move(object Argument)
        {
            var nextBlock = CurrentBlock[(WorldBlock.WorldBlockSide)Argument];

            if (nextBlock == null)
            {
                Console.WriteLine("Блока со стороны " + ((WorldBlock.WorldBlockSide)Argument).ToString() + " не существует");
                return;
            }

            CurrentBlock = nextBlock;
            Camp.SetWorldPosition(nextBlock.Position);
            Camp.Hero.WorldTurn();
        }
    public override void RegisteMouseEvent(ref UnityAction mapEnterAction, ref UnityAction <Land, PointerEventData> mapClickAction, ref UnityAction mapExitAction)
    {
        base.RegisteMouseEvent(ref mapEnterAction, ref mapClickAction, ref mapExitAction);
        mapEnterAction = delegate()
        {
            tip      = GlobalUImanager.Instance.LandTip.GetComponent <LandTip>();
            _showTip = true;
        };


        mapClickAction = delegate(Land clickLand, PointerEventData eventData)
        {
            Camp myCamp = BattleManager.Instance.MyCamp;
            if (eventData.button == PointerEventData.InputButton.Left && clickLand.CampID == myCamp.campID)
            {
                _lockUpdateMouse = true;
                tip.ShowSelf(false);
                GameObject MsgBoxObj = GlobalUImanager.Instance.OpenMsgBox(MsgBoxEnum.MsgBox2Btns);
                MsgBoxObj.GetComponent <MsgBox2Btns>().SetMsgBox("确定选择该地为首都吗?",
                                                                 () =>
                {
                    _lockUpdateMouse   = false;
                    myCamp.capitalLand = clickLand;
                    BattleManager.Instance.BattleMap.SetCapital(clickLand);
                    GlobalUImanager.Instance.CloseMsgBox(MsgBoxObj);

                    //发出战斗开始的事件
                    if (BattleManager.Instance.BattleStart != null)
                    {
                        BattleManager.Instance.BattleStart();
                    }
                    //进入我的回合状态
                    BattleMap battleMap = BattleManager.Instance.BattleMap;
                    BattleManager.Instance.CurBattleState = BattleManager.Instance.BattleStateDictionary[BattleStateEnum.MyRound];
                    BattleManager.Instance.CurBattleState.EnterStateWithMouse(ref battleMap.mapEnterAction, ref battleMap.mapClickAction, ref battleMap.mapExitAction);
                },
                                                                 () =>
                {
                    GlobalUImanager.Instance.CloseMsgBox(MsgBoxObj);
                    _lockUpdateMouse = false;
                });
            }
        };

        mapExitAction = delegate()
        {
            _showTip = false;
            tip      = null;
        };
    }
예제 #32
0
        public ActionResult BuildCamp(double lat, double lon, string name)
        {
            var  point = string.Format("POINT({1} {0})", lat, lon);
            Camp c     = CampManager.CreateUserCamp(point, Convert.ToInt32(Session["UserId"]), name);

            if (c == null)
            {
                return(Json("Camp couldn't be built!"));
            }
            else
            {
                return(Json("Camp built!"));
            }
        }
예제 #33
0
 public void SetUpCamp(int manhoursInvested)
 {
     campSetupTimeRemaining-=manhoursInvested;
     if (campSetupTimeRemaining<=0)
     {
         hasCamp=true;
         //print ("camp setup");
         campInRegion=new Camp();
         campToken.GetComponentInChildren<Text>().enabled=false;
         InventoryScreenHandler.mainISHandler.RefreshInventoryItems();
         campToken.color=Color.red;
         //GameObject campToken=Instantiate(campTokenPrefab);
         //campToken.transform.SetParent(this.transform);//,true);
         //campToken.transform.position=this.transform.position;
     }
     else
     {
         campToken.GetComponentInChildren<Text>().enabled=true;
         campToken.GetComponentInChildren<Text>().text=campSetupTimeRemaining.ToString();
     }
 }
예제 #34
0
파일: ViewStatus.cs 프로젝트: xqy/game
 /// <summary>
 /// 细胞hp变化
 /// </summary>
 /// <param name="data">细胞</param>
 /// <param name="num">hp的变化量</param>
 /// <param name="camp">如果hp小于零,将转换的阵营</param>
 private void hpChange(CellData data, int num, Camp camp)
 {
     if (data.hp + num > 0)
     {
         data.hp += num;
     }
     else
     {
         data.hp = CellConstant.INIT_HP;
         data.camp = camp;
         retreatAllTentacles(data.index);
     }
 }
예제 #35
0
        private void ChangeCamp(Controllable controllable, Camp camp)
        {
            if (camp.IsStacking)
            {
                var usedControllable = controllableUnits.FirstOrDefault(x => x.CurrentCamp == camp);
                usedControllable?.Stack(controllable.BlockedCamps.Last(), 2);
            }

            controllable.Stack(camp, 2);
        }
예제 #36
0
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;
	}
예제 #37
0
 public void CloseScreen()
 {
     campShown=false;
     assignedCamp=null;
     GetComponent<Canvas>().enabled=false;
 }