void Start() { gameControl = GetComponent<GameControl>(); et = GameObject.Find("EndTurn").GetComponent<EndTurn>(); selUnitLabelObject = (GUIText) Instantiate(Assets.Instance.SelUnitLabels); selUnitValueObject = (GUIText) Instantiate(Assets.Instance.SelUnitValues); selUnitNameObject = (GUIText) Instantiate(Assets.Instance.SelUnitName); selUnitObject = (GUITexture) Instantiate(Assets.Instance.SelUnitBox); playerStatsObject = (GUIText) Instantiate(Assets.Instance.PlayerStats); enemyStatsObject = (GUIText) Instantiate(Assets.Instance.EnemyStats); HideSelUnitBox(); HideSelUnitInfo(); }
public void SubscribeEndTurn(EndTurn del) { _endTurnEvent += del; }
public void UnsubscribeEndTurn(EndTurn del) { _endTurnEvent -= del; }
public void Start() { endTurn = FindObjectOfType <EndTurn>(); }
// Update is called once per frame void Update() { if (endTurn == null) { endTurn = FindObjectOfType <EndTurn>(); } else { if (isLocalPlayer) { //deselect unit if it is not their turn if (endTurn.turn != gameObject.GetComponent <CharacterStatus>().teamNum || gameObject.GetComponent <CharacterStatus>().currentHealth < 0) { //select the unit isSelected = false; _unit.SelectedUnitChanged(); } //check whether a spell has been cast upon the owner of this script and if so //ensure that they were not selected as the spell was cast if (targetedBySpell) { isSelected = false; } //if the left mouse button is pressed if (Input.GetButtonUp("Fire1")) { //if the cursor is not over a UI element //if (EventSystem.current.IsPointerOverGameObject() == false) //{ //cast a ray from the main camera to the cursor ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Debug.DrawLine(ray.origin, hit.point); Vector3 selectedPosition = new Vector3(hit.point.x, hit.point.y - hit.point.y - .416f, hit.point.z); if (hit.collider == _characterAbilities.GetComponentInParent <CapsuleCollider>()) { //if they are not having an ability cast upon them if (targetedBySpell == false) { if (endTurn.turn == gameObject.GetComponent <CharacterStatus>().teamNum && gameObject.GetComponent <CharacterStatus>().currentHealth > 0) { //select the unit isSelected = true; _unit.SelectedUnitChanged(); _unit._map.charSelect = true; } } //someone just cast an ability on this unit - do not select this unit //and the spell has been cast so we are no longer being targeted by an ability else { targetedBySpell = false; } } //if we selected a position away from the unit possessing this script else { //if the owner of this scrip is selected if (isSelected) { if (hit.collider.tag == "UI") { hit = new RaycastHit(); } //if we selected a different unit else if (hit.collider.tag == "Unit") { //if we are casting a ability if (castingSpell) { //inform targeted unit that it is being casted upon so that it //does not set itself as selected hit.collider.gameObject.GetComponent <MoveInput>().targetedBySpell = true; //we finished casting our ability castingSpell = false; } //if we were not casting an ability else { //de-select this unit isSelected = false; _unit.UnhighlightWalkableTiles(); } } //if we selcted the ground somewhere else { //if we were not using an ability if (castingSpell == false) { //if we were not trying to move if (_unit.moveToggle == false) { //de-select this unit isSelected = false; _unit._map.charSelect = false; } } //if we were casting an ability else { //de-select the ability castingSpell = false; _unit.UnhighlightWalkableTiles(); } } } } } //} } } } }
public void EndTurnClicked() { EndTurn?.Invoke(); }
public void HandleMessage(Packet msg) { switch (msg.Type) { case PacketType.Voice: Server.SendMessageToAll(msg); break; case PacketType.DeclareWinner: Server.DeclareWinner(((DeclareWinner)msg).Id); Server.StartMatch(true); break; case PacketType.EndTurn: { EndTurn endTurn = (EndTurn)msg; SelectedCards.Clear(); foreach (CardInfo info in endTurn.Cards) { SelectedCards.Add(info.Value); } CardCount -= endTurn.Cards.Count; Ready = true; Server.SendMessageToAllExcept(new SetStatus(Id, false), Id); break; } case PacketType.LobbyBeginGame: Server.SendMessageToAll(new BeginGame()); Server.State = Server.States.InGame; Server.StartMatch(false); Server.Greet(); break; case PacketType.ServerJoin: { ServerJoin serverJoin = (ServerJoin)msg; // Check version if (serverJoin.Version != Program.Version) { Connection.Disconnect("Host is running on a different version."); return; } Name = serverJoin.Name; Server.SendMessageToAllExcept(new PlayerNew(Name, Id), Id); foreach (ServerClient c in Server.Clients.Where(a => a.Id != Id)) { Connection.SendMessage(new PlayerNew(c.Name, c.Id)); } Verified = true; Server.SendMessageToAllExcept(new ChatMessage(String.Format("{0} has joined the game!", Name)), Id); break; } case PacketType.ChatMessage: { ChatMessage chatMessage = (ChatMessage)msg; Server.SendMessageToAllExcept(new ChatMessage(chatMessage.Value), Id); break; } default: Console.WriteLine("Unhandled packet {0}", msg.Type.ToString()); break; } }
public void StartToProcessOptions(JSONObject jsonObject) { int count = 0; foreach (JSONObject j in jsonObject["options"].list) { switch (j["option_type"].str) { case MULLIGAN: //WHY DID I DO THIS /* * Mulligan m = new Mulligan(); * m.n = count; * // m.cardGuid = j["cardGuid"].str; * count++; * if(!options.ContainsKey(m.cardGuid)) * { * options.Add(m.cardGuid, new List<Option>()); * } * * options[m.cardGuid].Add(m); * */ break; case NO_MULLIGAN: NoMulligan nm = new NoMulligan(); nm.n = count; count++; if (!options.ContainsKey(noMulliganKey)) { options.Add(noMulliganKey, new List <Option>()); } options[noMulliganKey].Add(nm); break; case END_TURN: EndTurn et = new EndTurn(); et.n = count; count++; if (!options.ContainsKey(END_TURN)) { options.Add(END_TURN, new List <Option>()); } options[END_TURN].Add(et); break; case PLAY_CARD: PlayCardOption pc = new PlayCardOption(); pc.n = count; pc.cardGuid = j["source_uid"].n.ToString(); pc.targetGuid = j["target_uid"].n.ToString(); count++; if (!options.ContainsKey(pc.cardGuid)) { options.Add(pc.cardGuid, new List <Option>()); } options[pc.cardGuid].Add(pc); break; case ATTACK: AttackOption a = new AttackOption(); a.n = count; a.cardGuid = j ["source_uid"].n.ToString(); a.defenderGuid = j["target_uid"].n.ToString(); count++; if (!options.ContainsKey(a.cardGuid)) { options.Add(a.cardGuid, new List <Option>()); } options[a.cardGuid].Add(a); break; case HERO_POWER: break; case PLAY_SPELL: PlaySpellOption ps = new PlaySpellOption(); ps.n = count; ps.cardGuid = j["cardGuid"].n.ToString(); ps.target = j["targetGuid"].n.ToString(); count++; if (!options.ContainsKey(ps.cardGuid)) { options.Add(ps.cardGuid, new List <Option>()); } options[ps.cardGuid].Add(ps); break; default: break; } } }
private void MakeTurn() { EndTurn.Execute(PlayerState.Number); }
public AI1(GameStatus gameStatus, User user, Create create, EndTurn endTurn, Attack attack, Move move, int mapXColumn, int mapYRow) : base(gameStatus, user, create, endTurn, attack, move, mapXColumn, mapYRow) { initializeCards(); }