// Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            BackButtonClick();
        }

        if (GameUtil.isAttackModeOn && GameUtil.attackIcelandIndex != -1 && GameUtil.CheckIsIcelandSelected(GameUtil.selectedIceLand[0]))
        {
            //get both object and store into one object
            GameObject attackOn   = mainSpawnContainer.transform.GetChild(GameUtil.attackIcelandIndex).gameObject;
            GameObject attackFrom = mainSpawnContainer.transform.GetChild(GameUtil.selectedIceLand[0]).gameObject;


            #region Send Attacking planes
            //get number of planes to be removed
            int removePlane = 0;
            if (attackFrom.GetComponent <StaticIceland>().totalPlane > 1)
            {
                //deactivated activated round iceland border of attackFrom iceland
                attackFrom.transform.GetChild(1).gameObject.SetActive(false);

                removePlane = Mathf.RoundToInt(attackFrom.GetComponent <StaticIceland>().totalPlane / 2);
                attackFrom.GetComponent <StaticIceland>().totalPlane = removePlane;    //deduct plane to e removed from attackFrom iceland

                int attackerTotalPlane = attackOn.GetComponent <StaticIceland>().totalPlane;

                //generate one plane object and assign to object
                GameObject planeObject = Instantiate(planePrefab, GameObject.Find("AttackingPlaneTransform").transform /*mainSpawnContainer.gameObject.transform*/);

                //set position of plane to attackFrom's position
                planeObject.transform.position = attackFrom.transform.position;

                //assign plane to be remove from attackTo iceland and allow to start animation moving towards attackTo object
                planeObject.GetComponent <AttackingPlane>().totalPlane     = removePlane;
                planeObject.GetComponent <AttackingPlane>().placeAtInitial = true;

                //assign details that needs to be changed after plane reach to the destination iceland
                Color attackerColor = attackFrom.GetComponentInChildren <Image>().color;
                planeObject.transform.GetChild(0).GetComponent <Image>().color = new Color(attackerColor.r, attackerColor.g, attackerColor.b, 0.7f);
                planeObject.GetComponent <AttackingPlane>().playerCode         = attackFrom.GetComponent <StaticIceland>().playerCode;
                planeObject.GetComponent <AttackingPlane>().teamCode           = attackFrom.GetComponent <StaticIceland>().teamCode;
                planeObject.GetComponent <AttackingPlane>().playerType         = attackFrom.GetComponent <StaticIceland>().playerType;
                planeObject.GetComponent <AttackingPlane>().color    = attackFrom.GetComponent <StaticIceland>().color;
                planeObject.GetComponent <AttackingPlane>().isFree   = false;
                planeObject.GetComponent <AttackingPlane>().isStatic = false;

                //planeObject.transform.SetSiblingIndex();

                //start attacking
                GameUtil.GenerateAttackPlane(planeObject, attackFrom.transform, attackOn.transform);

                //reset attack
                GameUtil.ResetAttackMode();
            }
            #endregion
        }
    }
    void AttackManagerMulti()
    {
        Debug.Log("icelandIndex: " + iceLandIndex + " playerType: " + playerType);
        print(GameUtil.isAttackModeOn + " form " + GameUtil.selectedIceLand[0] + " on iceLandIndex " + iceLandIndex);

        if (color == GameManager.Inst.MyColor)
        {
            if (GameUtil.CheckIsIcelandSelected(iceLandIndex))
            {
                this.transform.GetChild(1).gameObject.SetActive(false);
                GameUtil.ResetAttackMode();
            }
            else
            {
                string selectedPlayerType = GameUtil.GetIcelandValueUsingKey <string>(this.transform.parent.gameObject, GameUtil.selectedIceLand[0], "playerType");
                Debug.Log("selected iceland type: " + selectedPlayerType);

                if (selectedPlayerType == playerType && GameUtil.isAttackModeOn)
                {
                    if (GameUtil.isAttackModeOn)
                    {
                        GameUtil.attackIcelandIndex = iceLandIndex;
                        //reset timer if attacked on anyone
                        timeNotAttacked = 0;
                    }
                }
                else
                {
                    this.transform.GetChild(1).gameObject.SetActive(true);
                    GameUtil.selectedIceLand = new int[20];

                    GameUtil.selectedIceLand[0] = iceLandIndex;

                    Debug.Log("Iceland selection " + GameUtil.selectedIceLand[0]);

                    GameUtil.isAttackModeOn = true;
                }
            }
        }
        else /*if (playerType == "computer")*/
        {
            if (GameUtil.isAttackModeOn)
            {
                GameUtil.attackIcelandIndex = iceLandIndex;

                //reset timer if attacked on anyone
                timeNotAttacked = 0;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetMouseButtonDown(0))
        //{
        //    for (int i = 0; i < mainSpawnContainer.transform.childCount; i++)
        //    {
        //        print("<color> ♥ ♥ ♣ ♣ ♦ ♦</color>" + mainSpawnContainer.transform.childCount);
        //        mainSpawnContainer.transform.GetChild(i).transform.GetChild(1).gameObject.SetActive(false);
        //        //GameUtil.ResetAttackMode();
        //    }
        //}

        if (GameUtil.isAttackModeOn && GameUtil.attackIcelandIndex != -1)
        {
            for (int i = 0; i < GameUtil.numberofselected; i++)
            {
                if (GameUtil.CheckIsIcelandSelected(GameUtil.selectedIceLand[i]))
                {
                    print("-=-=-=-GameUtil.attackIcelandIndex=-=->" + GameUtil.attackIcelandIndex);
                    //get both object and store into one object
                    GameObject attackOn   = mainSpawnContainer.transform.GetChild(GameUtil.attackIcelandIndex).gameObject;
                    GameObject attackFrom = mainSpawnContainer.transform.GetChild(GameUtil.selectedIceLand[i]).gameObject;

                    #region Send Attacking planes
                    //get number of planes to be removed
                    int removePlane = 0;
                    if (attackFrom.GetComponent <Iceland>().totalPlane > 1 && attackFrom.GetComponent <Iceland>().playerType == "human")
                    {
                        //deactivated activated round iceland border of attackFrom iceland
                        attackFrom.transform.GetChild(1).gameObject.GetComponent <Image>().fillAmount = 0;

                        removePlane = Mathf.RoundToInt(attackFrom.GetComponent <Iceland>().totalPlane / 2);
                        attackFrom.GetComponent <Iceland>().totalPlane = removePlane;    //deduct plane to e removed from attackFrom iceland

                        int attackerTotalPlane = attackOn.GetComponent <Iceland>().totalPlane;

                        //generate one plane object and assign to object
                        GameObject planeObject = Instantiate(planePrefab, GameObject.Find("AttackingPlaneTransform").transform /*mainSpawnContainer.gameObject.transform*/);

                        //set position of plane to attackFrom's position
                        planeObject.transform.position = attackFrom.transform.position;

                        //assign plane to be remove from attackTo iceland and allow to start animation moving towards attackTo object
                        planeObject.GetComponent <AttackingPlane>().totalPlane     = removePlane;
                        planeObject.GetComponent <AttackingPlane>().placeAtInitial = true;

                        //assign details that needs to be changed after plane reach to the destination iceland
                        Color attackerColor = attackFrom.GetComponentInChildren <Image>().color;
                        planeObject.transform.GetChild(0).GetComponent <Image>().color = new Color(attackerColor.r, attackerColor.g, attackerColor.b, 0.7f);
                        planeObject.GetComponent <AttackingPlane>().playerCode         = attackFrom.GetComponent <Iceland>().playerCode;
                        planeObject.GetComponent <AttackingPlane>().teamCode           = attackFrom.GetComponent <Iceland>().teamCode;
                        planeObject.GetComponent <AttackingPlane>().playerType         = attackFrom.GetComponent <Iceland>().playerType;
                        planeObject.GetComponent <AttackingPlane>().color    = attackFrom.GetComponent <Iceland>().color;
                        planeObject.GetComponent <AttackingPlane>().isFree   = false;
                        planeObject.GetComponent <AttackingPlane>().isStatic = false;

                        //planeObject.transform.SetSiblingIndex();

                        //start attacking
                        GameUtil.GenerateAttackPlane(planeObject, attackFrom.transform, attackOn.transform);
                    }
                }
            }
            //reset attack
            GameUtil.ResetAttackMode();

            #endregion
        }
    }
    // will be click of iceland
    void AttackManager()
    {
        Debug.Log("icelandIndex: " + iceLandIndex + " playerType: " + playerType);

        print(GameUtil.isAttackModeOn + " form " + GameUtil.selectedIceLand[0] + " on iceLandIndex " + iceLandIndex);

        if (playerType == "human")
        {
            if (GameUtil.CheckIsIcelandSelected(iceLandIndex))
            {
                this.transform.GetChild(1).gameObject.SetActive(false);
                GameUtil.ResetAttackMode();
            }
            else
            {
                if (isMyIcaland)
                {
                    //if (this.transform.parent.gameObject.name == "SpawnPointsOne")
                    //{
                    //    selectedPlayerType = GameUtil.GetIcelandValueUsingKey<string>(this.transform.gameObject, GameUtil.selectedIceLand[0], "human");
                    //}
                    selectedPlayerType = "human";
                    Debug.Log(" if ♥ ♥ this.transform.parent.gameObject:  " + this.transform.parent.gameObject.name);
                    //selectedPlayerType = GameUtil.GetIcelandValueUsingKey<string>(this.transform.parent.gameObject, GameUtil.selectedIceLand[0], "human");
                }
                else
                {
                    Debug.Log("else ♠ ♠ this.transform.parent.gameObject:  " + this.transform.parent.gameObject.name);
                    selectedPlayerType = GameUtil.GetIcelandValueUsingKey <string>(this.transform.parent.gameObject, GameUtil.selectedIceLand[0], "playerType");
                }
                Debug.Log("selected iceland type: " + selectedPlayerType);

                if (selectedPlayerType == playerType && GameUtil.isAttackModeOn)
                {
                    if (GameUtil.isAttackModeOn)
                    {
                        GameUtil.attackIcelandIndex = iceLandIndex;
                        //reset timer if attacked on anyone
                        timeNotAttacked = 0;
                        Debug.Log("GameUtil.isAttackModeOn: " + GameUtil.isAttackModeOn);
                    }
                }
                else
                {
                    this.transform.GetChild(1).gameObject.SetActive(true);
                    GameUtil.selectedIceLand = new int[20];

                    GameUtil.selectedIceLand[0] = iceLandIndex;

                    Debug.Log("Iceland selection " + GameUtil.selectedIceLand[0]);

                    GameUtil.isAttackModeOn = true;
                }
            }
        }
        else /*if (playerType == "computer")*/
        {
            if (GameUtil.isAttackModeOn)
            {
                GameUtil.attackIcelandIndex = iceLandIndex;

                //reset timer if attacked on anyone
                timeNotAttacked = 0;
            }
        }
    }
Esempio n. 5
0
    public void AttackManagerMulti()
    {
        Debug.Log("icelandIndex: " + iceLandIndex + " playerType: " + playerType);
        print(GameUtil.isAttackModeOn + " form " + GameUtil.selectedIceLand[0] + " on iceLandIndex " + iceLandIndex);

        if (SceneManager.GetActiveScene().name.Equals("MultiPlayerGamePlayScene"))
        {
            for (int i = 0; i < GameUtil.numberofselected; i++)
            {
                Iceland attack = GamePlayManagerMultiPlayer.inst.mainSpawnContainer.transform.GetChild(GameUtil.selectedIceLand[i]).gameObject.GetComponent <Iceland>();
                if (GameUtil.isAttackModeOn && GameUtil.selectedIceLand[0].ToString() != iceLandIndex.ToString() && attack.color == GameManager.Inst.MyColor)
                {
                    print("<Color><b> totalPlane ♥  </b></Color>>> " + GamePlayManagerMultiPlayer.inst.mainSpawnContainer.transform.GetChild(GameUtil.selectedIceLand[i]).gameObject.GetComponent <Iceland>().totalPlane);

                    Dictionary <string, string> pairs = new Dictionary <string, string>();
                    pairs.Add("isAttackModeOn", GameUtil.isAttackModeOn.ToString());
                    pairs.Add("selectedIceLand", GameUtil.selectedIceLand[i].ToString());
                    pairs.Add("iceLandIndex", iceLandIndex.ToString());
                    pairs.Add("totalPlane", GamePlayManagerMultiPlayer.inst.mainSpawnContainer.transform.GetChild(GameUtil.selectedIceLand[i]).gameObject.GetComponent <Iceland>().totalPlane.ToString());
                    pairs.Add("deviceId", SystemInfo.deviceUniqueIdentifier);
                    socketIOComponent.Emit("Attack", new JSONObject(pairs));
                }
            }
        }

        if (color == GameManager.Inst.MyColor)
        {
            if (GameUtil.CheckIsIcelandSelected(iceLandIndex))
            {
                Multiplayerrest();
                //this.transform.GetChild(1).gameObject.SetActive(false);
                //GameUtil.ResetAttackMode();
            }
            else
            {
                string selectedPlayerType = GameUtil.GetIcelandValueUsingKey <string>(this.transform.parent.gameObject, GameUtil.selectedIceLand[0], "playerType");
                Debug.Log("selected iceland type: " + selectedPlayerType);

                if (selectedPlayerType == playerType && GameUtil.isAttackModeOn)
                {
                    if (GameUtil.isAttackModeOn)
                    {
                        GameUtil.attackIcelandIndex = iceLandIndex;
                        //reset timer if attacked on anyone
                        timeNotAttacked = 0;
                    }
                }
                else
                {
                    //this.transform.GetChild(1).gameObject.SetActive(true);
                    //GameUtil.selectedIceLand = new int[20];

                    //GameUtil.selectedIceLand[0] = iceLandIndex;
                    print("-=-=-=->Attack3333333-=-=->" + gameObject.name);
                    this.transform.GetChild(1).gameObject.SetActive(true);
                    this.transform.GetChild(1).gameObject.GetComponent <Image>().fillAmount = 1;
                    // GameUtil.selectedIceLand = new int[20];

                    GameUtil.numberofselected++;
                    GameUtil.selectedIceLand[GameUtil.numberofselected - 1] = iceLandIndex;

                    Debug.Log("Iceland selection " + GameUtil.selectedIceLand[0] + GameUtil.selectedIceLand.Length);

                    GameUtil.isAttackModeOn = true;
                }
            }
        }
        else /*if (playerType == "computer")*/
        {
            if (GameUtil.isAttackModeOn)
            {
                GameUtil.attackIcelandIndex = iceLandIndex;

                //reset timer if attacked on anyone
                timeNotAttacked = 0;
            }
        }
    }
Esempio n. 6
0
    // will be click of iceland
    public void AttackManager()
    {
        Debug.Log("icelandIndex: " + iceLandIndex + " playerType: " + playerType);

        print(GameUtil.isAttackModeOn + " form " + GameUtil.selectedIceLand[0] + " on iceLandIndex " + iceLandIndex);

        if (SceneManager.GetActiveScene().name.Equals("MultiPlayerGamePlayScene"))
        {
            if (GameUtil.isAttackModeOn)
            {
                Dictionary <string, string> pairs = new Dictionary <string, string>();
                pairs.Add("isAttackModeOn", GameUtil.isAttackModeOn.ToString());
                pairs.Add("selectedIceLand", GameUtil.selectedIceLand[0].ToString());
                pairs.Add("iceLandIndex", iceLandIndex.ToString());
                pairs.Add("deviceId", SystemInfo.deviceUniqueIdentifier);
                socketIOComponent.Emit("Attack", new JSONObject(pairs));
            }
        }

        if (playerType == "human")
        {
            if (GameUtil.CheckIsIcelandSelected(iceLandIndex))
            {
                print("check" + GameUtil.CheckIsIcelandSelected(iceLandIndex));
                Singleplayerreset();
                //this.transform.GetChild(1).gameObject.SetActive(false);
                //print("-=-=-=->Attack111111-=-=->" + gameObject.name);
                //this.transform.GetChild(1).gameObject.GetComponent<Image>().fillAmount = 0;
                //GameUtil.ResetAttackMode();
            }
            else
            {
                string selectedPlayerType = GameUtil.GetIcelandValueUsingKey <string>(this.transform.parent.gameObject, GameUtil.selectedIceLand[0], "playerType");
                Debug.Log("selected iceland type: " + selectedPlayerType);

                if (selectedPlayerType == playerType && GameUtil.isAttackModeOn)
                {
                    if (GameUtil.isAttackModeOn)
                    {
                        print("-=-=-=->Attack22222222-=-=->" + gameObject.name);
                        GameUtil.attackIcelandIndex = iceLandIndex;
                        //reset timer if attacked on anyone
                        timeNotAttacked = 0;
                    }
                }
                else
                {
                    print("-=-=-=->Attack3333333-=-=->" + gameObject.name);
                    this.transform.GetChild(1).gameObject.SetActive(true);
                    this.transform.GetChild(1).gameObject.GetComponent <Image>().fillAmount = 1;
                    // GameUtil.selectedIceLand = new int[20];

                    GameUtil.numberofselected++;
                    GameUtil.selectedIceLand[GameUtil.numberofselected - 1] = iceLandIndex;


                    Debug.Log("Iceland selection " + GameUtil.selectedIceLand[0] + "-=-=-=->" + GameUtil.numberofselected);

                    GameUtil.isAttackModeOn = true;
                }
            }
        }
        else /*if (playerType == "computer")*/
        {
            if (GameUtil.isAttackModeOn)
            {
                this.transform.GetChild(1).gameObject.SetActive(true);
                this.transform.GetChild(1).gameObject.GetComponent <Image>().fillAmount = 0;
                print("-=-=-=->Attack4444444-=-=->" + gameObject.name);
                GameUtil.attackIcelandIndex = iceLandIndex;

                //reset timer if attacked on anyone
                timeNotAttacked = 0;
            }
        }
    }
Esempio n. 7
0
    void ServerData(bool isAttack, int attackIndex, int selectediceland, int totalPlaneServer, string plane_id, Vector3 pos)
    {
        //print("attack on " + mainSpawnContainer.transform.GetChild(attackIndex).gameObject.name);
        //print("attack from " + mainSpawnContainer.transform.GetChild(selectediceland).gameObject.name);

        print("Server Call but not forther" + GameUtil.CheckIsIcelandSelected(selectediceland));

        if (isAttack && attackIndex != -1 && GameUtil.CheckIsIcelandSelected(GameUtil.selectedIceLand[selectediceland]))
        {
            //get both object and store into one object
            GameObject attackOn   = mainSpawnContainer.transform.GetChild(selectediceland).gameObject;
            GameObject attackFrom = mainSpawnContainer.transform.GetChild(attackIndex).gameObject;
            print("attack on " + attackOn.name);
            print("attack from " + attackFrom.name);
            #region Send Attacking planes
            //get number of planes to be removed
            int removePlane = 0;
            if (attackFrom.GetComponent <Iceland>().totalPlane > 1)
            {
                //deactivated activated round iceland border of attackFrom iceland
                //attackFrom.transform.GetChild(1).gameObject.SetActive(false);
                attackFrom.transform.GetChild(1).gameObject.GetComponent <Image>().fillAmount = 0;

                removePlane = Mathf.RoundToInt(totalPlaneServer / 2);
                attackFrom.GetComponent <Iceland>().totalPlane = removePlane;    //deduct plane to e removed from attackFrom iceland

                int attackerTotalPlane = attackOn.GetComponent <Iceland>().totalPlane;

                //generate one plane object and assign to object
                GameObject planeObject = Instantiate(planePrefab, GameObject.Find("AttackingPlaneTransform").transform /*mainSpawnContainer.gameObject.transform*/);

                //set position of plane to attackFrom's position
                if (pos == Vector3.zero)
                {
                    planeObject.transform.position = attackFrom.transform.position;
                }
                else
                {
                    planeObject.transform.position = pos;
                }
                //assign plane to be remove from attackTo iceland and allow to start animation moving towards attackTo object
                planeObject.GetComponent <AttackingPlane>().AttackingPlane_ID = plane_id;
                planeObject.GetComponent <AttackingPlane>().totalPlane        = removePlane;
                planeObject.GetComponent <AttackingPlane>().placeAtInitial    = true;

                //assign details that needs to be changed after plane reach to the destination iceland
                Color attackerColor = attackFrom.GetComponentInChildren <Image>().color;
                planeObject.transform.GetChild(0).GetComponent <Image>().color = new Color(attackerColor.r, attackerColor.g, attackerColor.b, 0.7f);
                planeObject.GetComponent <AttackingPlane>().playerCode         = attackFrom.GetComponent <Iceland>().playerCode;
                planeObject.GetComponent <AttackingPlane>().teamCode           = attackFrom.GetComponent <Iceland>().teamCode;
                planeObject.GetComponent <AttackingPlane>().playerType         = attackFrom.GetComponent <Iceland>().playerType;
                planeObject.GetComponent <AttackingPlane>().color    = attackFrom.GetComponent <Iceland>().color;
                planeObject.GetComponent <AttackingPlane>().isFree   = false;
                planeObject.GetComponent <AttackingPlane>().isStatic = false;

                //Adding the Attacking plane in the Dictionary
                serverObject.Add(plane_id, planeObject.GetComponent <AttackingPlane>());

                //planeObject.transform.SetSiblingIndex();

                //start attacking
                GameUtil.GenerateAttackPlane(planeObject, attackFrom.transform, attackOn.transform);

                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().totalPlane);
                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().color);
                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().playerCode);
                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().teamCode);
                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().isFree);
                print("Attck from to here => " + planeObject.GetComponent <AttackingPlane>().isStatic);
                print("Attck from to here => " + attackOn.name);

                //reset attack
                GameUtil.ResetAttackMode();
            }
            #endregion
        }
    }