Example #1
0
    // Use this for initialization
    public override void OnSyncedStart()         // ???? Should this be called for both Navis???
    {
        if (localOwner.Id == owner.Id)           // If player owns this Navi
        {
            GameObject.Find("Chip Bay").GetComponent <Chip_Hand> ().navi = this.gameObject;
            chip_hand = GameObject.Find("Chip Bay").GetComponent <Chip_Hand>();
            chip_hand.init();
            GameObject.Find("Swiper").GetComponent <Swiper> ().Navi     = this;
            GameObject.Find("Field Swipe").GetComponent <Swiper>().Navi = this;
            field.Tapref.Navi       = this;         // field is holding reference to tapper/keylistener to allow disabled
            field.KeyListenref.Navi = this;
            GameObject.Find("Buster Button").GetComponent <Buster> ().navi   = this;
            GameObject.Find("Draw Button").GetComponent <Draw_Button>().navi = this;
            NPbutton = GameObject.Find("NaviPower Button").GetComponent <NaviPower>();
            NPbutton.Init(this);
        }
        // Setting the player's number for easy acess
        if (owner.Id <= 1)
        {
            playerNumber = 1;
        }
        if (owner.Id == 2)
        {
            playerNumber = 2;
        }

        if (localOwner.Id <= 1)           // If I'm Player 1, Set these spawnpoints (LOCAL ONLY!)
        {
            if (playerNumber == 1)
            {
                shot_handler.playerA = this;                 // Also invert shot_handler's player refs
                field_space          = 7;
                UpdateRowColumn();
            }
            if (playerNumber == 2)
            {
                field_space          = 10;
                shot_handler.playerB = this;
                UpdateRowColumn();
            }
        }
        if (localOwner.Id == 2)           // If I'm Player 2, Switch these spawnpoints (LOCAL ONLY!)
        {
            if (playerNumber == 1)
            {
                shot_handler.playerB = this;
                field_space          = 10;
                UpdateRowColumn();
            }
            if (playerNumber == 2)
            {
                shot_handler.playerA = this;
                field_space          = 7;
                UpdateRowColumn();
            }             // If I'm Player 2, Switch tile ownership (LOCAL ONLY!)
            //row1
            field.spaces [0].owner = 2; field.spaces [1].owner = 2; field.spaces [2].owner = 2;
            field.spaces [3].owner = 1; field.spaces [4].owner = 1; field.spaces [5].owner = 1;
            //row2
            field.spaces [6].owner = 2; field.spaces [7].owner = 2; field.spaces [8].owner = 2;
            field.spaces [9].owner = 1; field.spaces [10].owner = 1; field.spaces [11].owner = 1;
            //row3
            field.spaces [12].owner = 2; field.spaces [13].owner = 2; field.spaces [14].owner = 2;
            field.spaces [15].owner = 1; field.spaces [16].owner = 1; field.spaces [17].owner = 1;
        }

        //	@@@ Setting UI elements based on player ownership @@@
        if (localOwner.Id != owner.Id)           // If player DOESN"T own this Navi
        {
            tsTransform.scale = new TSVector(-tsTransform.scale.x, tsTransform.scale.y, tsTransform.scale.z);
            health_dispB      = GameObject.Find("HealthB");
            cust_dispB        = GameObject.Find("CustB");
            AC_dispB          = GameObject.Find("ActiveChipB");
            AC_dispB.SetActive(false);
            held_dispB           = GameObject.Find("ChipCountB");
            player_face_B        = GameObject.Find("PlayerFaceB").GetComponent <Image>();
            player_face_B.sprite = navi_face;
            GameObject.Find("End_Panel").GetComponent <End_Panel>().naviB = this;
            //cust_dispB.GetComponent<Cust>().navi = this;
            GameObject.Find("PlayerIDB").GetComponent <Text>().text = owner.Name;
            gameObject.tag   = "Enemy Navi";
            buster_offset.x *= -1;              // flip x offset values to reflect flipped sprite
            int i = 0;
            while (i < throw_offset.Length)
            {
                throw_offset[i].y *= -1;
                i++;
            }
        }
        if (localOwner.Id == owner.Id || localOwner.Id == null)           // If owner or offline
        {
            health_dispA = GameObject.Find("HealthA");
            cust_dispA   = GameObject.Find("CustA");
            AC_dispA     = GameObject.Find("ActiveChipA");
            AC_dispA.SetActive(false);
            player_face_A        = GameObject.Find("PlayerFaceA").GetComponent <Image>();
            player_face_A.sprite = navi_face;
            GameObject.Find("End_Panel").GetComponent <End_Panel>().naviA = this;
            //cust_dispA.GetComponent<Cust>().navi = this;
            GameObject.Find("PlayerIDA").GetComponent <Text>().text = owner.Name;
            gameObject.tag = "My Navi";
        }
    }