internal void AddResource(GameResourceType type, uint value) { Resource.Add(type, (int)value); if (type > 0) { MainForm.Instance.AddTip(string.Format("|获得|{0}|{1}||x{2}", HSTypes.I2ResourceColor((int)type), HSTypes.I2Resource((int)type), value), "White"); AchieveBook.CheckByCheckType("resource"); } }
public override void AddResource(GameResourceType type, int number) { if (number > 0) { UserProfile.InfoBag.AddResource(type, (uint)number); } else if (number < 0) { UserProfile.InfoBag.SubResource(type, (uint)(-number)); } }
internal void Add(GameResourceType type, int value) { switch ((int)type) { case 0: Gold += value; break; case 1: Lumber += value; break; case 2: Stone += value; break; case 3: Mercury += value; break; case 4: Carbuncle += value; break; case 5: Sulfur += value; break; case 6: Gem += value; break; } }
internal bool Has(GameResourceType type, int value) { switch ((int)type) { case 0: return Gold >= value; case 1: return Lumber >= value; case 2: return Stone >= value; case 3: return Mercury >= value; case 4: return Carbuncle >= value; case 5: return Sulfur >= value; case 6: return Gem >= value; } return false; }
internal bool HasResource(GameResourceType type, uint value) { return(Resource.Has(type, (int)value)); }
internal bool HasResource(GameResourceType type, uint value) { return Resource.Has(type, (int)value); }
internal void SubResource(GameResourceType type, uint value) { Resource.Add(type, (int)-value); }
public virtual void AddResource(GameResourceType type, int number) { }
public GameException(GameResourceType rs, string message = "Run Out") : base(message) { GameResourceType = rs; }
private void SetResourcePrefabs(int aIForNPCSeed) { LimitedMinedResourceInfo[] hexTypeToLimitedMinedResourceInfo = new LimitedMinedResourceInfo[(int)WorldMap.HexType.AllResources]; foreach (LimitedMinedResourceInfo resourceInfo in limitedMinedResourceInfoList.resourceInfos) { WorldMap.HexType hexType = WorldMap.GameResourceTypeToHexType(resourceInfo.gameResourceType); hexTypeToLimitedMinedResourceInfo[(int)hexType] = resourceInfo; } int currentAIForNPCOffset = aIForNPCSeed; for (int x = 0; x < cellColumns; ++x) { for (int y = 0; y < cellRows; ++y) { WorldMap.HexCell hexCell = worldMap.worldAreaInfo.area[x, y]; if (WorldMap.IsResourceOnlyType(hexCell.hexType)) { GameResourceType gameResourceType = WorldMap.HexTypeToGameResourceType(hexCell.hexType); GameObject resourceDeposit = Instantiate(resourceDepositPrefab, worldMap.GetHexPosition(new Vector2Int(x, y)), Quaternion.identity, resourcesTransform); ResourceSprite resourceSprite = resourceDeposit.GetComponent <ResourceSprite>(); resourceSprite.InitWithGameResourceType(gameResourceType); ResourceDeposit resourceDepositScript = resourceDeposit.GetComponent <ResourceDeposit>(); LimitedMinedResourceInfo limitedMinedResourceInfo = hexTypeToLimitedMinedResourceInfo[(int)hexCell.hexType]; float resourceAmount = limitedMinedResourceInfo.minAmount + Mathf.Pow(hexCell.resourceAmount / maxPossibleResourceValuePerCell, limitedMinedResourceInfo.power) * (limitedMinedResourceInfo.maxAmount - limitedMinedResourceInfo.minAmount); resourceDepositScript.SetResourceType(gameResourceType, resourceAmount); hexCell.indexInResourceArray = (short)worldMap.resourceDepositArray.Count; worldMap.worldAreaInfo.area[x, y] = hexCell; worldMap.resourceDepositArray.Add(resourceDepositScript); worldMap.resourceDepositIndicesArray.Add(new Vector2Int(x, y)); } else if (hexCell.hexType == WorldMap.HexType.Mountain) { GameObject mountain = Instantiate(mountainPrefab, worldMap.GetHexPosition(new Vector2Int(x, y)), Quaternion.identity, mountainsTransform); EnvironmentHeightParameter environmentHeightParameter = mountain.GetComponent <EnvironmentHeightParameter>(); environmentHeightParameter.InitHeight(hexCell.resourceAmount / maxPossibleResourceValuePerCell); } else if (hexCell.hexType == WorldMap.HexType.Crater) { GameObject crater = Instantiate(craterPrefab, worldMap.GetHexPosition(new Vector2Int(x, y)), Quaternion.identity, cratersTransform); EnvironmentHeightParameter environmentHeightParameter = crater.GetComponent <EnvironmentHeightParameter>(); environmentHeightParameter.InitHeight(hexCell.resourceAmount / maxPossibleResourceValuePerCell); } else if (hexCell.hexType == WorldMap.HexType.ColonyMainBase) { GameObject mainBaseLocation = Instantiate(mainBaseLocationPrefab, worldMap.GetHexPosition(new Vector2Int(x, y)), Quaternion.identity, mainBaseLocationsTransform); ColonyTeritory colonyTeritory = mainBaseLocation.GetComponent <ColonyTeritory>(); Vector3[] positions = worldMap.GetHexRings(worldMap.GetHexPosition(new Vector2Int(x, y)), 1, colonyRaduis); bool isPlayer = worldMap.colonyMainBaseArray.Count == 0; colonyTeritory.InitAvailableHexes(new List <Vector3>(positions), isPlayer); if (!isPlayer) { AIForNPC aIForNPC = mainBaseLocation.GetComponent <AIForNPC>(); aIForNPC.worldMap = worldMap; aIForNPC.freezer = freezer; aIForNPC.colonyRaduis = colonyRaduis; aIForNPC.seed = currentAIForNPCOffset; aIForNPC.enabled = true; ++currentAIForNPCOffset; } hexCell.indexInColonyMainBaseArray = (short)worldMap.colonyMainBaseArray.Count; worldMap.worldAreaInfo.area[x, y] = hexCell; worldMap.colonyMainBaseArray.Add(mainBaseLocation); worldMap.colonyMainBaseIndicesArray.Add(new Vector2Int(x, y)); } } } }
internal void AddResource(GameResourceType type, uint value) { Resource.Add(type, value); MainTipManager.AddTip(string.Format("|获得|{0}|{1}||x{2}", HSTypes.I2ResourceColor((int)type), HSTypes.I2Resource((int)type), value), "White"); }
/// <summary> /// A发送过来,传输给另一个端的B /// 添加农民 /// </summary> /// <param name="rs"></param> public void SendAddFarmer(GameResourceType rs) { // Debug.Log("Call PRC!"); photonView.RPC("RPC_AddFarmer", RpcTarget.Others, rs); }
public void addition() { GameResourceType type1 = GameResourceTest.getTestGameResourceType(id: 1); GameResourceType type2 = GameResourceTest.getTestGameResourceType(id: 2); GameResourceType typeN = null; SingularYield singleYield1 = getTestSingularGameResourceYield(type1, 100); SingularYield singleYield2 = getTestSingularGameResourceYield(type1, 200); SingularYield singleYield3 = getTestSingularGameResourceYield(type1, -300); SingularYield singleYield4 = getTestSingularGameResourceYield(type2, 400); ResourceYield yield1 = GetTestFinishedGameResourceYield( singleYield1 ); ResourceYield yield2 = GetTestFinishedGameResourceYield( singleYield2, singleYield4 ); ResourceYield yield3 = GetTestFinishedGameResourceYield( singleYield3 ); MutableResourceYield yieldU1 = new MutableResourceYield(); MutableResourceYield yieldU2 = yield1.cloneUnlocked(); ResourceYield sumI = yield1.combinePure(NOTHING_CONST); Assert.That(sumI.Count, Is.EqualTo(1)); Assert.That(sumI, Contains.Key(type1)); Assert.That(sumI[type1], Is.EqualTo(100)); ResourceYield sum1 = yield1.combinePure(yield2); Assert.That(sum1.Count, Is.EqualTo(2)); Assert.That(sum1, Contains.Key(type1)); Assert.That(sum1, Contains.Key(type2)); Assert.That(sum1[type1], Is.EqualTo(300)); Assert.That(sum1[type2], Is.EqualTo(400)); //Purity (A) Assert.That(yield1.Count, Is.EqualTo(1)); Assert.That(yield1, Contains.Key(type1)); Assert.That(yield1[type1], Is.EqualTo(100)); ResourceYield sum2 = yield1.combinePure(yield3); Assert.That(sum2.Count, Is.EqualTo(1)); Assert.That(sum2, Contains.Key(type1)); Assert.That(sum2[type1], Is.EqualTo(-200)); //Purity (B) Assert.That(yield3.Count, Is.EqualTo(1)); Assert.That(yield3, Contains.Key(type1)); Assert.That(yield3[type1], Is.EqualTo(-300)); Assert.That(yieldU1.Count, Is.EqualTo(0)); Assert.That(yieldU1, Does.Not.ContainKey(type1)); ResourceYield sumU1 = yieldU1.combineDirty(yield1); Assert.That(yieldU1.Count, Is.EqualTo(1)); Assert.That(yieldU1, Contains.Key(type1)); Assert.That(yieldU1[type1], Is.EqualTo(100)); Assert.That(yieldU1, Is.EqualTo(sumU1)); Assert.That(yieldU2.Count, Is.EqualTo(1)); Assert.That(yieldU2, Contains.Key(type1)); Assert.That(yieldU2[type1], Is.EqualTo(100)); ResourceYield sumU2 = yieldU2.combineDirty(yield2); Assert.That(yieldU2.Count, Is.EqualTo(2)); Assert.That(yieldU2, Contains.Key(type1)); Assert.That(yieldU2, Contains.Key(type2)); Assert.That(yieldU2[type1], Is.EqualTo(300)); Assert.That(yieldU2[type2], Is.EqualTo(400)); Assert.That(yieldU2, Is.EqualTo(sumU2)); }
public void scaling() { GameResourceType type1 = GameResourceTest.getTestGameResourceType(id: 1); GameResourceType type2 = GameResourceTest.getTestGameResourceType(id: 2); GameResourceType typeN = null; SingularYield singleYield1 = getTestSingularGameResourceYield(type: type1, value: 100); SingularYield singleYield2 = getTestSingularGameResourceYield(type: type1, value: 200); SingularYield singleYield4 = getTestSingularGameResourceYield(type: type2, value: -400); ResourceYield yield1 = GetTestFinishedGameResourceYield( singleYield1 ); ResourceYield yield2 = GetTestFinishedGameResourceYield( singleYield2, singleYield4 ); ResourceYield?yieldN1 = null; MutableResourceYield yieldU1 = new MutableResourceYield(); MutableResourceYield yieldU2 = yield1.cloneUnlocked(); MutableResourceYield prodI = yield1.scalePure(1); Assert.That(prodI.Count, Is.EqualTo(1)); Assert.That(prodI, Contains.Key(type1)); Assert.That(prodI[type1], Is.EqualTo(100)); MutableResourceYield prod2 = yield2.scalePure(2); Assert.That(prod2.Count, Is.EqualTo(2)); Assert.That(prod2, Contains.Key(type1)); Assert.That(prod2[type1], Is.EqualTo(400)); Assert.That(prod2, Contains.Key(type2)); Assert.That(prod2[type2], Is.EqualTo(-800)); //Purity (A) Assert.That(yield2.Count, Is.EqualTo(2)); Assert.That(yield2, Contains.Key(type1)); Assert.That(yield2[type1], Is.EqualTo(200)); Assert.That(yield2, Contains.Key(type2)); Assert.That(yield2[type2], Is.EqualTo(-400)); ResourceYield prodN1 = yieldN1.scalePure(2); Assert.That(prodN1.Count, Is.EqualTo(0)); Assert.That(prodN1, Does.Not.ContainKey(type1)); ResourceYield prodN2 = yieldN1 * 2; Assert.That(prodN2.Count, Is.EqualTo(0)); Assert.That(prodN2, Does.Not.ContainKey(type1)); ResourceYield prodU1 = yieldU1.scaleDirty(2); Assert.That(prodU1.Count, Is.EqualTo(0)); Assert.That(prodU1, Does.Not.ContainKey(type1)); Assert.That(yieldU2.Count, Is.EqualTo(1)); Assert.That(yieldU2, Contains.Key(type1)); Assert.That(yieldU2[type1], Is.EqualTo(100)); ResourceYield prodU2 = yieldU2.scaleDirty(2); Assert.That(yieldU2.Count, Is.EqualTo(1)); Assert.That(yieldU2, Contains.Key(type1)); Assert.That(yieldU2[type1], Is.EqualTo(200)); Assert.That(yieldU2, Is.EqualTo(prodU2)); }
public void RPC_SubtractFarmer(GameResourceType rs) { playerBSideOnline.SubtractFarmer(rs); }
public void SendSubtractFarmer(GameResourceType rs) { photonView.RPC("RPC_SubtractFarmer", RpcTarget.Others, rs); }
public void RPC_AddFarmer(GameResourceType rs) { // Debug.Log("On PRC!"); playerBSideOnline.AddFarmer(rs); }