示例#1
0
    // Use this for initialization
    void Awake()
    {
        mainCamAudioSource = Camera.main.GetComponent <AudioSource> ();

        potatoButtonObj    = GameObject.Find("PotatoButton");
        cloudButtonObj     = GameObject.Find("CloudButton");
        paladinButtonObj   = GameObject.Find("PaladinButton");
        vampireButtonObj   = GameObject.Find("VampireButton");
        mercyButtonObj     = GameObject.Find("MercyButton");
        reinhardtButtonObj = GameObject.Find("ReinhardtButton");

        potatoButton    = potatoButtonObj.GetComponent <Button> ();
        cloudButton     = cloudButtonObj.GetComponent <Button> ();
        paladinButton   = paladinButtonObj.GetComponent <Button> ();
        vampireButton   = vampireButtonObj.GetComponent <Button> ();
        mercyButton     = mercyButtonObj.GetComponent <Button> ();
        reinhardtButton = reinhardtButtonObj.GetComponent <Button> ();

        potatoButton.interactable    = false;
        cloudButton.interactable     = false;
        paladinButton.interactable   = false;
        vampireButton.interactable   = false;
        mercyButton.interactable     = false;
        reinhardtButton.interactable = false;


        buildButton  = GameObject.Find("BuildButtonText").GetComponent <BuildButtonPress>();
        highlightSFX = Resources.Load <AudioClip> ("Sounds/UI/UIMouseOverSound");

        tooltipMessage = "T - Toggle Send Mode\n\nSend units to build your income and attack the enemy!";
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (gmObject == null)
        {
            gmObject    = GameObject.Find("GameManager");
            buildButton = GameObject.Find("BuildButtonText").GetComponent <BuildButtonPress>();
            sendButton  = GameObject.Find("SendButtonText").GetComponent <SendButtonPress>();
        }
        else if (gm == null)
        {
            gm = gmObject.GetComponent <GameManager>();
        }

        if (myID == "" || myID == "Player(Clone)")
        {
            myID = myPN.playerUniqueIdentity;
            Debug.Log(myID);
        }
        else if (mySpawner == null)
        {
            if (gm != null)
            {
                int myIdx = gm.MyPlayerIndex(myID);

                if (myIdx == -1)
                {
                    Debug.Log("My index is not found yet");
                }
                else
                {
                    if (myIdx == 1)
                    {
                        Debug.Log("Set Spawner");
                        mySpawner    = GameObject.Find("EnemySpawn2").GetComponent <SpawnUnit>();
                        enemySpawner = GameObject.Find("EnemySpawn1").GetComponent <SpawnUnit>();
                        myFinish     = GameObject.Find("FinishLine1").GetComponent <FinishLine> ();
                        enemyFinish  = GameObject.Find("FinishLine2").GetComponent <FinishLine> ();
                    }
                    else if (myIdx == 0)
                    {
                        Debug.Log("Set Spawner");
                        mySpawner    = GameObject.Find("EnemySpawn1").GetComponent <SpawnUnit>();
                        enemySpawner = GameObject.Find("EnemySpawn2").GetComponent <SpawnUnit>();
                        myFinish     = GameObject.Find("FinishLine2").GetComponent <FinishLine> ();
                        enemyFinish  = GameObject.Find("FinishLine1").GetComponent <FinishLine> ();
                    }
                }
            }
        }

        if (mySpawnID.IsEmpty())
        {
            if (mySpawner != null)
            {
                Debug.Log("Set Spawn ID");
                mySpawnID = mySpawner.GetComponent <NetworkIdentity> ().netId;

                mySpawner.sendPlayer = gameObject;

                enemySpawner.attackPlayer = gameObject;

                myFinish.SetPlayerToHurt(gameObject, myID);
                myFinish.SetMyPlayer(myID);
                enemyFinish.setOtherPlayer(gameObject, myID);
            }
        }

        if (!isLocalPlayer)
        {
            return;
        }
        else if (gm != null)
        {
            if (gm.gameRunning)
            {
                if (cursorReset == true)
                {
                    cursorReset = false;
                }
                CheckButtons();                  //Checks if any buttons are pressed
            }
            else
            {
                if (cursorReset == false)
                {
                    cursorReset = true;
                    Cursor.SetCursor(normalCursor, hotSpot, CursorMode.Auto);
                    Cursor.visible = true;
                }
            }
        }
    }