Esempio n. 1
0
        public void LoadPlayer(PlayerHolder p, PlayerStatUI statUI)
        {
            if (p == null)
            {
                return;
            }
            currentPlayer   = p;
            p.currentHolder = this;
            foreach (CardInstance c in p.handCards)
            {
                Settings.SetParentForCard(c.viz.gameObject.transform, handCardsGrid.value.transform);
                //c.viz.gameObject.transform.SetParent(handCardsGrid.value.transform);
            }

            foreach (CardInstance c in p.cardsDown)
            {
                Settings.SetParentForCard(c.viz.gameObject.transform, cardsDownGrid.value.transform);
                //c.viz.gameObject.transform.SetParent(cardsDownGrid.value.transform);
            }

            foreach (ResourceHolder c in p.resourceList)
            {
                Settings.SetParentForCard(c.cardObj.gameObject.transform, resourceCardsGrid.value.transform);
                //c.cardObj.gameObject.transform.SetParent(handCardsGrid.value.transform);
            }
            p.statUI = statUI;
            p.LoadPlayerOnStatUI();
        }
Esempio n. 2
0
 public void OnDeHighlight(PlayerHolder player)
 {
     if (!isSelected)
     {
         highlighter.SetActive(false);
     }
 }
Esempio n. 3
0
        // Update is called once per frame
        void Update()
        {
            if (switchPlayer)
            {
                switchPlayer = false;
                if (EnemyOfPlayer(currentPlayer))
                {
                    playerOneHolder.LoadPlayer(EnemyOfPlayer(currentPlayer), statUI[0]);
                    otherPlayerHolder.LoadPlayer(currentPlayer, statUI[1]);
                    currentPlayer = EnemyOfPlayer(currentPlayer);
                }
            }

            bool turnCompleted = turns[turnIndex].Excute();

            if (turnCompleted)
            {
                turnIndex++;
                if (turnIndex >= turns.Length)
                {
                    turnIndex = 0;
                }
                turns[turnIndex].OnTurnStart();
                currentPlayer  = turns[turnIndex].player;
                turnName.value = turns[turnIndex].player.userName;
                onTurnChanged.Raise();
            }

            if (currentState != null)
            {
                currentState.OnTick(Time.deltaTime);
            }
        }
        public override void OnStartPhase()
        {
            PlayerHolder p = Settings.gameManager.currentPlayer;

            if (p.attackingCards.Count == 0)
            {
                forceExit = true;
                return;
            }
            for (int i = 0; i < p.attackingCards.Count; i++)
            {
                CardInstance   inst   = p.attackingCards[i];
                Card           c      = inst.viz.cards;
                CardProperties attack = c.GetProperty(attackElement);
                if (attack == null)
                {
                    Debug.LogError("This card cannot be attacked!");
                    continue;
                }
                //in Card.cs - line 14 add :
                //public CardProperties GetProperty(Element e){
                // for(int i = 0; i < properties.Length; i++){
                // { if(properties[i].element == e){
                //    return properties[i];
                //    } return null;
                //}
            }
        }
        public void RPC_SpawnPlayer(int photonId, Vector3 targetPosition, Quaternion targetRot)
        {
            PlayerHolder p = mRef.GetPlayer(photonId);

            if (p.states != null)
            {
                p.states.SpawnPlayer(targetPosition, targetRot);
            }
        }
Esempio n. 6
0
 public void LoadPlayerOnActive(PlayerHolder p)
 {
     if (playerOneHolder.currentPlayer != p)
     {
         PlayerHolder prevHolder = playerOneHolder.currentPlayer;
         LoadPlayerOnHolder(prevHolder, otherPlayerHolder, statUI[1]);
         LoadPlayerOnHolder(p, playerOneHolder, statUI[0]);
     }
 }
Esempio n. 7
0
 private void Awake()
 {
     singleton = this;
     allPlayer = new PlayerHolder[turns.Length];
     for (int i = 0; i < allPlayer.Length; i++)
     {
         allPlayer[i] = turns[i].player;
     }
     currentPlayer = turns[0].player;
 }
Esempio n. 8
0
 public override void Excute(PlayerHolder player)
 {
     foreach (CardInstance c in player.cardsDown)
     {
         if (c.isFlatFooted)
         {
             c.SetFlatFooted(false);
         }
     }
 }
        public void AddNewPlayer(NetworkPrint print)
        {
            Debug.Log("(4) MultiplayerManager: AddNewPlayerCalled called");
            print.transform.parent = mRef.referencesParent;
            PlayerHolder playerH = mRef.AddNewPlayer(print);

            if (print.isLocal)
            {
                mRef.localPlayer = playerH;
            }
        }
Esempio n. 10
0
        public PlayerHolder EnemyOfPlayer(PlayerHolder p)
        {
            foreach (PlayerHolder player in allPlayer)
            {
                if (p != player)
                {
                    return(player);
                }
            }

            return(null);
        }
        public void RPC_KillPlayer(int photonId)
        {
            PlayerHolder p = mRef.GetPlayer(photonId);

            if (p.states != null)
            {
                p.states.KillPlayer();
            }
            else
            {
                Debug.LogError("Player holder is missing for: " + photonId);
            }
        }
        public void BroadCastPlayerIsHitBy(int photonId, int shooterId)
        {
            PlayerHolder p = mRef.GetPlayer(shooterId);

            p.killCount++;
            photonView.RPC("RPC_SyncKillCount", RpcTarget.All, shooterId, p.killCount);

            if (p.killCount >= winKillCount)
            {
                Debug.Log("Match Over");
                BroadcastMatchOver(shooterId);
            }
        }
        public void RPC_BroadcastPlayerHealth(int photonId, int health)
        {
            PlayerHolder p = mRef.GetPlayer(photonId);

            p.health = health;

            if (p == mRef.localPlayer)
            {
                if (p.health <= 0)
                {
                    BroadcastKillPlayer(photonId);
                }
            }
        }
        public void RPC_ShootWeapon(int photonId, Vector3 dir, Vector3 origin)
        {
            if (photonId == mRef.localPlayer.photonId)
            {
                return;
            }

            PlayerHolder shooter = mRef.GetPlayer(photonId);

            if (shooter == null)
            {
                return;
            }

            ballistics.ClientShoot(shooter.states, dir, origin);
        }
        public PlayerHolder AddNewPlayer(NetworkPrint p)
        {
            Debug.Log("(5) MultiplayerReferences: AddNewPlayer called");
            if (!IsUniquePlayer(p.photonId))
            {
                return(null);
            }

            PlayerHolder playerHolder = new PlayerHolder
            {
                photonId = p.photonId,
                print    = p,
                health   = 100
            };

            players.Add(playerHolder);
            return(playerHolder);
        }
Esempio n. 16
0
        public override bool IsValid()
        {
            GameManager  gm    = GameManager.singleton;
            PlayerHolder p     = gm.currentPlayer;
            int          count = p.cardsDown.Count;

            for (int i = 0; i < p.cardsDown.Count; i++)
            {
                if (p.cardsDown[i].isFlatFooted)
                {
                    count--;
                }
            }
            if (count > 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 17
0
        public void OnPhotonInstantiate(PhotonMessageInfo info)
        {
            states = GetComponent <StateManager>();
            states.InitReferences();
            mTransform = this.transform;
            object[] data = photonView.InstantiationData;

            states.photonId = (int)data[0];
            string modelId = (string)data[2];

            states.LoadCharacterModel(modelId);

            MultiplayerManager m = MultiplayerManager.singleton;

            this.transform.parent = m.GetMRef().referencesParent;

            PlayerHolder playerHolder = m.GetMRef().GetPlayer(states.photonId);

            playerHolder.states = states;

            string weaponId = (string)data[1];

            Debug.Log("Weapon ID: " + weaponId);
            states.inventory.weaponID = weaponId;

            if (photonView.IsMine)
            {
                states.isLocal = true;
                states.SetCurrentState(local);
                initLocalPlayer.Execute(states);
            }
            else
            {
                states.isLocal = false;
                states.SetCurrentState(client);
                initClientPlayer.Execute(states);
                states.multiplayerListener = this;
            }
        }
Esempio n. 18
0
        public void PickNewCardFormDeck(PlayerHolder p)
        {
            if (p.allCards.Count == 0)
            {
                Debug.Log("Game Over");
                return;
            }
            string cardID = p.allCards[0];

            p.allCards.RemoveAt(0);
            ResourcesManager rm  = Settings.GetResourcesManager();
            GameObject       go  = Instantiate(cardPrefab) as GameObject;
            CardViz          viz = go.GetComponent <CardViz>();

            viz.Load(rm.GetCardInstance(cardID));
            CardInstance inst = go.GetComponent <CardInstance>();

            inst.currentLogic = p.handCardsLogic;
            inst.owner        = p;
            Settings.SetParentForCard(go.transform, p.currentHolder.handCardsGrid.value);
            p.handCards.Add(inst);
        }
Esempio n. 19
0
        public override bool IsCompleted()
        {
            PlayerHolder p = Settings.gameManager.currentPlayer;
            PlayerHolder e = Settings.gameManager.EnemyOfPlayer(p);

            if (p.attackingCards.Count == 0)
            {
                //Debug.Log("No card Attack");
                return(true);
            }

            Dictionary <CardInstance, BlockCardInstance> dictBlock = Settings.gameManager.GetBlockInstances();

            for (int i = 0; i < p.attackingCards.Count; i++)
            {
                CardInstance   inst   = p.attackingCards[i];
                Card           c      = inst.viz.card;
                CardProperties attack = c.GetProperty(elementAttack);
                if (attack == null)
                {
                    //Debug.Log("Cant not attack with card");
                    continue;
                }

                int attackValue      = attack.intValue;
                BlockCardInstance bi = GetBlockInstanceOfAttacker(inst, dictBlock);
                if (bi != null)
                {
                    for (int j = 0; j < bi.blocker.Count; j++)
                    {
                        CardProperties def = c.GetProperty(elementDefence);
                        if (def == null)
                        {
                            Debug.Log("Card No defence");
                            continue;
                        }

                        attackValue -= def.intValue;

                        if (def.intValue <= attackValue)
                        {
                            // Card Die
                        }
                    }
                }

                if (attackValue <= 0)
                {
                    attackValue = 0;
                    inst.CardInstanceToGraveyard();
                }

                p.DropCard(inst, false);
                p.currentHolder.SetCardOnDown(inst);
                inst.SetFlatFooted(true);
                e.DoDame(attack.intValue);
            }
            Settings.gameManager.ClearBlockCardInstance();
            p.attackingCards.Clear();
            return(true);
        }
Esempio n. 20
0
 public override void Excute(PlayerHolder player)
 {
     GameManager.singleton.PickNewCardFormDeck(player);
 }
Esempio n. 21
0
 public override void Excute(PlayerHolder player)
 {
     GameManager.singleton.LoadPlayerOnActive(player);
 }
Esempio n. 22
0
 public abstract void Excute(PlayerHolder player);
Esempio n. 23
0
 public void OnSelect(PlayerHolder player)
 {
     isSelected = true;
     highlighter.SetActive(true);
     player.stateManager.currChar = this; // will automatically deselect the previous character
 }
Esempio n. 24
0
 // when the character is deselected
 public void OnDeselect(PlayerHolder player)
 {
     isSelected = false;
     highlighter.SetActive(false);
 }
Esempio n. 25
0
 public void OnHighlight(PlayerHolder player)
 {
     highlighter.SetActive(true);
 }
Esempio n. 26
0
 public void LoadPlayerOnHolder(PlayerHolder p, CardHolder h, PlayerStatUI statUI)
 {
     h.LoadPlayer(p, statUI);
 }