示例#1
0
    // Start is called before the first frame update
    void Awake()
    {
        string parentName = transform.parent.gameObject.name;

        netID = short.Parse(parentName.Remove(0, 3));
        flagBox.material.color = GuiManager.GetColorByNetID(netID);
        startingRotation       = this.transform.rotation;
    }
示例#2
0
    //init returns the newly-active voteInfo data
    public virtual VoteInfo init(MapSelect mapSelect, short voteableID)
    {
        if (decisionCallback == null)
        {
            Debug.Log("ERROR IN: " + this.gameObject.name + " object, decision callback was null!");
        }

        //init state info and stuff
        voteInfo        = new VoteInfo();
        this.voteableID = voteableID;
        this.mapSelect  = mapSelect;
        this.menuState  = mapSelect.GetMapSelectState();
        this.bounds     = GetComponent <RectTransform> ();
        float votePrefabHeight = votePrefab.GetComponent <RectTransform> ().rect.height;

        //init and position votepip objects
        if (votePips == null)
        {
            votePips = new GameObject[4];
        }
        for (short i = 0; i < 4; ++i)
        {
            if (votePips[i] == null)
            {
                votePips[i] = Instantiate(votePrefab, this.gameObject.transform);
            }
            votePips[i].GetComponent <Image> ().color = GuiManager.GetColorByNetID(i);
            votePips[i].SetActive(false);
            float   scaleFactor = (float)i / 3.0f;
            Vector3 newPosition = new Vector3(bounds.rect.width * scaleFactor - bounds.rect.width / 2, bounds.rect.height / 2 + votePrefabHeight + topOffset, 0);
            votePips[i].GetComponent <RectTransform> ().localPosition = newPosition;
        }

        //setup onclick listener to toggle vote
        GetComponent <Button> ().onClick.RemoveAllListeners();
        GetComponent <Button> ().onClick.AddListener(() => {
            if (StateManager.state.isServer)
            {
                RecieveVote(0, !voteInfo.votes[StateManager.state.network.networkID]);
            }
            else
            {
                //send a vote command for this object
                StateManager.state.network.SendMessage(new Vote {
                    networkID = StateManager.state.network.networkID,
                    votableID = this.voteableID,
                    vote      = !voteInfo.votes[StateManager.state.network.networkID]
                });
            }
        });

        //setup callback for when decision is true
        triggered = false;

        //return voteInfo back to MapSelect to be used as a reference
        return(voteInfo);
    }
示例#3
0
 private void SetPlayerConnected(short id, bool isConnected)
 {
     if (isConnected)
     {
         players[id].color = GuiManager.GetColorByNetID(id);
     }
     else
     {
         players[id].color = new Color(.45f, .45f, .45f, .45f);
     }
     mapState.connectedPlayers[id] = isConnected;
 }
示例#4
0
    // Start is called before the first frame update
    void Awake()
    {
        string parentName = transform.parent.gameObject.name;

        flagPos = new Vector3(this.transform.position.x, this.transform.position.y + flagPrefab.transform.position.y, this.transform.position.z);
        if (flag == null)
        {
            flag = Instantiate(flagPrefab, flagPos, flagPrefab.transform.rotation, this.transform.parent).GetComponent <FlagActions>();
        }
        flag.setHome(this.gameObject);
        flagIsHome = true;
        netID      = short.Parse(parentName.Remove(0, 3));
        platformRenderer.material.color = GuiManager.GetColorByNetID(netID);
    }