public void AddGoldHeroRPC(int viewID, string hero) { GoldCoin toAdd = PhotonView.Find(viewID).gameObject.GetComponent <GoldCoin>(); Hero toAddTo = findHero(hero); toAddTo.heroInventory.addGold2(toAdd); }
public static GoldCoin Factory(string hero) { GoldCoin goldCoin = GoldCoin.Factory(); GameManager.instance.findHero(hero).heroInventory.AddItem(goldCoin); return(goldCoin); }
public void DropItem() { if (token is SmallToken) { GameManager.instance.MainHero.heroInventory.RemoveSmallToken((SmallToken)this.token); Cell cell = GameManager.instance.MainHero.Cell; cell.Inventory.AddToken(this.token); } else if (token is BigToken) { GameManager.instance.MainHero.heroInventory.RemoveBigToken((BigToken)this.token); Cell cell = GameManager.instance.MainHero.Cell; cell.Inventory.AddToken(this.token); } else if (token is Helm) { GameManager.instance.MainHero.heroInventory.RemoveHelm((Helm)this.token); Cell cell = GameManager.instance.MainHero.Cell; cell.Inventory.AddToken(this.token); } else if (token is GoldCoin) { GameManager.instance.MainHero.heroInventory.RemoveGold(1); Cell cell = GameManager.instance.MainHero.Cell; Token goldCoin = GoldCoin.Factory(); cell.Inventory.AddToken(goldCoin); } HideHeroActions(); }
protected override void LoadContent() { this.IsMouseVisible = true; stages = GameStages.Game_Stage; // Create a new SpriteBatch, which can be used to draw textures. this.spriteBatch = new SpriteBatch(this.GraphicsDevice); GfxHandler.Load(this.Content); GoldCoin coin = new GoldCoin(new Vector2(300, 300), "TestObjects/coin"); // testEnemyTex = Content.Load<Texture2D>(@"TestObjects/cockSprite"); Vector2 enemyPos = new Vector2(550, 350); Vector2 pos = new Vector2( GlobalVariables.WindowWidth / 2 - 140, GlobalVariables.WindowHeight / 2); this.sampleEnemy = new Enemy(enemyPos, @"TestObjects/cockSprite", 100, 100, 1, this.testLevel); this.testPlayer = new TestChar(pos, @"Player/p1Rotation", 100, 100, 2, this.testLevel); this.testLevel = new Level(@"..\..\..\Content\Maps\testMap2.txt", this.testPlayer); this.testLevel.Assets.Add(coin); this.sampleEnemy.Level = this.testLevel; this.testPlayer.Level = this.testLevel; this.testLevel.Enemies.Add(this.sampleEnemy); // TODO: Get Width and Heignt based on the level size? this.graphics.PreferredBackBufferWidth = GlobalVariables.WindowWidth; // set this value to the desired width of your window this.graphics.PreferredBackBufferHeight = GlobalVariables.WindowHeight; // set this value to the desired height of your window this.graphics.ApplyChanges(); }
public override void SetUpInStart() { base.SetUpInStart(); ShowItemsUICanvas.gameObject.SetActive(false); myGameManager = FindObjectOfType <MyGameManager>(); Tower[] towers = new Tower[AvailableTowers.Count]; Sprite[] towersSprite = new Sprite[AvailableTowers.Count]; for (int i = 0; i < AvailableTowers.Count; i++) { towers[i] = AvailableTowers[i].gameObject.GetComponent <Tower>(); GoldCoin g1 = new GoldCoin(towers[i].GoldToBuy); GoldCoin g2 = new GoldCoin(towers[i].GoldToSell); towers[i].BuyPrice = new Price(g1); towers[i].SellPrice = new Price(g2); towersSprite[i] = AvailableTowersSprite[i].GetComponent <SpriteRenderer>().sprite; } m_transform = this.transform; Factory.prototypes = towers; Factory.prototypesSprite = towersSprite; }
public static void TriggerHeroGoldClick(GoldCoin gold) { if (heroGoldClick != null) { heroGoldClick(gold); } }
public static void TriggerCellGoldClick(GoldCoin gold) { if (cellGoldClick != null) { cellGoldClick(gold); } }
public static GoldCoin Factory(int cellID) { GoldCoin goldCoin = GoldCoin.Factory(); goldCoin.Cell = Cell.FromId(cellID); return(goldCoin); }
public override void ApplyEffect() { if (GameManager.instance.CurrentPlayer != GameManager.instance.MainHero) { return; } GoldCoin.Factory(Cell.Index); }
public static GoldCoin Factory() { GameObject goldCoinGO = PhotonNetwork.Instantiate("Prefabs/Tokens/GoldCoin", Vector3.zero, Quaternion.identity, 0); GoldCoin gold = goldCoinGO.GetComponent <GoldCoin>(); gold.Cell = null; return(gold); }
public override void SetUpInStart() { base.SetUpInStart(); GoldCoin g1 = new GoldCoin(GoldToBuy); GoldCoin g2 = new GoldCoin(GoldToSell); BuyPrice = new Price(g1); SellPrice = new Price(g2); sphereCollider = GetComponent <SphereCollider>(); sphereCollider.radius = Range; facingThreshold = Mathf.Clamp01(facingThreshold); }
void Finalize() { while (archerGold != 0) { GoldCoin.Factory("Archer"); archerGold--; } while (dwarfGold != 0) { GoldCoin.Factory("Dwarf"); dwarfGold--; } while (mageGold != 0) { GoldCoin.Factory("Mage"); mageGold--; } while (warriorGold != 0) { GoldCoin.Factory("Warrior"); warriorGold--; } while (archerWP != 0) { Hero a = GameManager.instance.findHero("Archer"); a.setWP(a.Willpower + 1); archerWP--; } while (dwarfWP != 0) { Hero a = GameManager.instance.findHero("Dwarf"); a.setWP(a.Willpower + 1); dwarfWP--; } while (mageWP != 0) { Hero a = GameManager.instance.findHero("Mage"); a.setWP(a.Willpower + 1); mageWP--; } while (warriorWP != 0) { Hero a = GameManager.instance.findHero("Warrior"); a.setWP(a.Willpower + 1); warriorWP--; } }
public void addGold2(GoldCoin gold) { string id = convertToKey(gold.GetComponent <PhotonView>().ViewID); golds.Add(id, (GoldCoin)gold); AllTokens.Add(id, (GoldCoin)gold); numOfGold++; if (GameManager.instance.MainHero.TokenName.Equals(parentHero)) { EventManager.TriggerInventoryUIHeroUpdate(this); EventManager.TriggerGoldUpdate(GameManager.instance.findHero(parentHero)); } else if (parentHero.Equals(CharChoice.choice.TokenName)) { EventManager.TriggerInventoryUIHeroPeak(this); } }
// Use this for initialization void Start () { Instance = this; roadO = GameObject.FindGameObjectWithTag("MainCamera"); roadScript = roadO.GetComponent<ForegroundScript>(); startPosition = new Vector3(30,getStartPosition(),-1); this.transform.position = startPosition; startTime = (float)Random.Range(0.0f,10.0f); currentSpeed = 0.0f; fastSpeed = 6.0f; slowSpeed = 4.0f; rotSpeed = 0.01f; rotPosition = 0.0f; }
void LoadGame(string directory) { // Load from json here // Heroes foreach (Hero hero in heroes) { hero.Load(directory); } // Cells CellStates Cells = FileManager.Load <CellStates>(directory + "/Cells.json"); foreach (CellState cellstate in Cells.cellStates) { foreach (string token in cellstate.inventory) { Type type = Type.GetType(token); if (type == typeof(Farmer)) { farmers.Add(Farmer.Factory(cellstate.index)); } else if (type == typeof(Gor)) { gors.Add(Gor.Factory(cellstate.index)); } else if (type == typeof(Skral)) { skrals.Add(Skral.Factory(cellstate.index)); } else if (type == typeof(Wardrak)) { wardraks.Add(Wardrak.Factory(cellstate.index)); } else if (type == typeof(TowerSkral)) { towerskrals.Add(TowerSkral.Factory(cellstate.index, players.Count)); } else if (type.IsSubclassOf(typeof(Fog))) { string id = type.ToString().Replace("Fog", ""); Fog.Load(id, type, cellstate.index); } else if (type == typeof(Well)) { wells.Add(Well.Factory(cellstate.index)); } // Items in cells if (PhotonNetwork.IsMasterClient) { if (type == typeof(GoldCoin)) { GoldCoin.Factory(cellstate.index); } else if (type.IsSubclassOf(typeof(SmallToken))) { type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index }); } else if (type.IsSubclassOf(typeof(BigToken))) { type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index }); } } } } // Narrator NarratorState narratorState = FileManager.Load <NarratorState>(directory + "/Narrator.json"); narrator.Load(narratorState); // Wells WellsState wellsState = FileManager.Load <WellsState>(directory + "/Wells.json"); foreach (int cellId in wellsState.wellsCellId) { bool found = false; foreach (Well well in wells) { if (well.Cell.Index == cellId) { found = true; break; } } // If not found, the well is empty if (!found) { wells.Add(Well.Factory(cellId, false)); } } }
void DistributeGold(int warriorGold, int archerGold, int dwarfGold, int mageGold) { GameObject distributeGoldGO = GameObject.Find("DistributeGold"); Hero warrior = heroes.Where(x => x.Type.ToString() == "Warrior").FirstOrDefault(); if (warriorGold > 0 && warrior != null) { while (warriorGold != 0) { if (GameManager.instance.MainHero.TokenName.Equals("Warrior")) { Token goldCoin = GoldCoin.Factory("Warrior"); } warriorGold--; } } Hero archer = heroes.Where(x => x.Type.ToString() == "Archer").FirstOrDefault(); if (archerGold > 0 && archer != null) { while (archerGold != 0) { if (GameManager.instance.MainHero.TokenName.Equals("Archer")) { Token goldCoin = GoldCoin.Factory("Archer"); } archerGold--; } } Hero dwarf = heroes.Where(x => x.Type.ToString() == "Dwarf").FirstOrDefault(); if (dwarfGold > 0 && dwarf != null) { while (dwarfGold != 0) { if (GameManager.instance.MainHero.TokenName.Equals("Dwarf")) { Token goldCoin = GoldCoin.Factory("Dwarf"); } dwarfGold--; } } Hero mage = heroes.Where(x => x.Type.ToString() == "Mage").FirstOrDefault(); if (mageGold > 0 && mage != null) { while (mageGold != 0) { if (GameManager.instance.MainHero.TokenName.Equals("Mage")) { Token goldCoin = GoldCoin.Factory("Mage"); } mageGold--; } } if (PhotonNetwork.IsMasterClient) { distributeGoldGO.SetActive(false); } }
public void OnTriggerStay(Collider other) { //Mean Cloudci if (other.gameObject.tag == "cloud") { if(cloudScript.currentLane == currentLane) { //Reduce Time //Reset Multiply //Add Stumble other.gameObject.transform.position = new Vector3 ( -30,0,-1); } } //Gold Coin else if (other.gameObject.tag == "goldCoin") { coinScript = other.gameObject.GetComponent<GoldCoin>(); if(coinScript.currentLane == currentLane) { other.transform.position = new Vector3(-30, other.transform.position.y, other.transform.position.z); } } //Empty Kettle else if (other.gameObject.tag == "kettleEmpty") { if( emptyKScript.currentLane == currentLane) { // //Reset Multiply //Add Stumbles other.gameObject.transform.position = new Vector3 ( -30,0,-1); } } //Full Kettle else if (other.gameObject.tag == "kettleFull") { if( fullKScript.currentLane == currentLane) { //Reset Multiply //Add Stumbles other.gameObject.transform.position = new Vector3 ( -30,0,-1); } } //Add Time else if (other.gameObject.tag == "timeClock") { if(clockScript.currentLane == currentLane) { //Add Time //AddTime(10); other.gameObject.transform.position = new Vector3 ( -30,0,-1); } } //Multiplyer up else if (other.gameObject.tag == "Shamrock" ) { if(shamScript.currentLane == currentLane) { //Up Multiplyer other.gameObject.transform.position = new Vector3(-30,0,-1); } } }
public void AddGold(GoldCoin gold) { int viewID = gold.GetComponent <PhotonView>().ViewID; GameManager.instance.photonView.RPC("AddGoldHeroRPC", RpcTarget.AllViaServer, new object[] { viewID, parentHero }); }