示例#1
0
 public void Start()
 {
     this.isInitialized = false;
     this.postRenderer  = this.GetComponent <PostRenderer>();
     if (this.postRenderer == null)
     {
         Debug.Log("Can't initialize post renderer. Moving to Update() to check.");
     }
 }
示例#2
0
        public void RpcLog()
        {
            //First, checks to see what type of recipient is receiving this message. If it's server, the output message should tell the user what the type is.
            Debug.Log("RPC: This is " + (this.isServer ? " Server" : " Client"));

            //Second, initialize everything that is common for both server and client.
            //Camera stuff
            GameObject[] cameraObjects = GameObject.FindGameObjectsWithTag("MainCamera");
            foreach (GameObject cam in cameraObjects)
            {
                GameObject minimap = GameObject.FindGameObjectWithTag("Minimap");
                if (minimap != null)
                {
                    Material borderMaterial = Resources.Load <Material>("Border");
                    if (borderMaterial != null)
                    {
                        if (cam.GetComponent <PostRenderer>() == null)
                        {
                            cam.AddComponent <PostRenderer>();
                        }
                        PostRenderer postRenderer = cam.GetComponent <PostRenderer>();
                        if (postRenderer != null)
                        {
                            postRenderer.borderMaterial = borderMaterial;
                            postRenderer.minimapCamera  = minimap.GetComponent <Camera>();
                            if (postRenderer.minimapCamera == null)
                            {
                                Debug.LogError("Unable to assign minimap camera to post renderer.");
                            }
                        }
                    }

                    if (cam.GetComponent <CameraPanning>() == null)
                    {
                        Debug.Log("Camera Panning is added to camera. Please check.");
                        CameraPanning panning = cam.AddComponent <CameraPanning>();
                        MinimapStuffs stuffs  = minimap.GetComponent <MinimapStuffs>();
                        if (stuffs != null)
                        {
                            stuffs.playerCameraPanning = panning;
                        }
                        panning.cameraPanning = true;
                    }
                    else
                    {
                        if (!cam.GetComponent <CameraPanning>().cameraPanning)
                        {
                            cam.GetComponent <CameraPanning>().cameraPanning = true;
                        }
                    }
                }
            }

            //Finally, initialize server only stuff or client only stuff.
            //Also, finally found a use-case for [Server] / [ServerCallback]. Simplifies things a bit.
            ServerInitialize();
        }
示例#3
0
 // Update is called once per frame
 public void Update()
 {
     if (!this.isInitialized)
     {
         if (this.postRenderer == null)
         {
             this.postRenderer = this.GetComponent <PostRenderer>();
             if (this.postRenderer != null)
             {
                 this.postRenderer.enabled = false;
             }
         }
     }
 }
    //NOTE(Thompson): This is equivalent to SetClientReady().
    public void SetLANHostReady()
    {
        this.LANHost.SetActive(false);

        GameMetricLogger.EnableLoggerHotkey();

        PostRenderer renderer = Camera.main.GetComponent <PostRenderer>();

        if (renderer != null)
        {
            renderer.enabled = true;
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }
 private void Start()
 {
     Instance      = this;
     lineMat       = new Material(Shader.Find("Unlit/Color"));
     lineMat.color = Color.green;
 }
    public void SetClientReady()
    {
        if (!ClientScene.ready)
        {
            if (ClientScene.Ready(this.networkManager.client.connection))
            {
                Camera       cam      = Camera.main.GetComponent <Camera>();
                PostRenderer renderer = cam.GetComponent <PostRenderer>();
                if (renderer != null)
                {
                    renderer.enabled = true;
                }
                MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
                if (stuffs != null)
                {
                    Camera minimapCamera = stuffs.GetComponent <Camera>();
                    minimapCamera.enabled      = true;
                    stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
                }
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(false);

                GameMetricLogger.EnableLoggerHotkey();

                NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
                foreach (NewSpawner spawn in spawners)
                {
                    if (spawn != null && spawn.hasAuthority)
                    {
                        NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                    }
                }

                GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
            }
            else
            {
                this.LANClientReady.SetActive(false);
                this.LANClientNotReady.SetActive(true);
            }
            if (ClientScene.localPlayers.Count == 0)
            {
                ClientScene.AddPlayer(0);
            }
        }
        else
        {
            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            Camera       cam      = Camera.main.GetComponent <Camera>();
            PostRenderer renderer = cam.GetComponent <PostRenderer>();
            if (renderer != null)
            {
                renderer.enabled = true;
            }
            MinimapStuffs stuffs = GameObject.FindObjectOfType <MinimapStuffs>();
            if (stuffs != null)
            {
                Camera minimapCamera = stuffs.GetComponent <Camera>();
                minimapCamera.enabled      = true;
                stuffs.playerCameraPanning = Camera.main.GetComponent <CameraPanning>();
            }

            this.LANClientReady.SetActive(false);
            this.LANClientNotReady.SetActive(false);

            string name = this.playerNameField.text;
            if (name.Length > 0)
            {
                GameMetricLogger.instance.playerName = name;
            }
            else
            {
                GameMetricLogger.instance.playerName = "Player";
            }
            GameMetricLogger.instance.difficultyEquations = this.difficultyDropdown.options[this.difficultyDropdown.value].text;
            GameMetricLogger.EnableLoggerHotkey();

            NewSpawner[] spawners = GameObject.FindObjectsOfType <NewSpawner>();
            foreach (NewSpawner spawn in spawners)
            {
                if (spawn != null && spawn.hasAuthority)
                {
                    NewSpawner.Instance.CmdSetReadyFlag(ClientScene.ready && !NetworkServer.active);
                }
            }

            GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        }

        Canvas         canvas = GameObject.FindObjectOfType <Canvas>();
        TooltipLocator loc    = canvas.GetComponent <TooltipLocator>();

        if (loc != null)
        {
            loc.tooltip.SetToolTipHidden(true);
        }
    }
示例#7
0
        public void Start()
        {
            //This is used to obtain inactive start locations. Start locations can randomly
            //be set to inactive, so I need a way to obtain these inactive game objects.
            this.starterObjects = GameObject.FindGameObjectWithTag("Respawn");
            if (this.starterObjects == null)
            {
                Debug.LogError("Cannot find starter object in scene.");
            }

            if (!this.hasAuthority)
            {
                return;
            }

            NetworkIdentity spawnerIdentity = this.GetComponent <NetworkIdentity>();

            if (!spawnerIdentity.localPlayerAuthority)
            {
                spawnerIdentity.localPlayerAuthority = true;
            }
            this.owner    = this.isServer ? spawnerIdentity.connectionToClient : spawnerIdentity.connectionToServer;
            this.isPaused = false;

            if (this.minimapCamera == null)
            {
                GameObject obj = GameObject.FindGameObjectWithTag("Minimap");
                if (obj != null)
                {
                    this.minimapCamera = obj.GetComponent <Camera>();
                    if (this.minimapCamera == null)
                    {
                        Debug.LogError("Failure to obtain minimap camera.");
                    }
                }
            }

            if (Camera.main.gameObject.GetComponent <PostRenderer>() == null)
            {
                PostRenderer renderer = Camera.main.gameObject.AddComponent <PostRenderer>();
                renderer.minimapCamera = this.minimapCamera;

                //NOTE(Thompson): See NOTE in NetworkManagerActions.StartLANClient().
                renderer.enabled = false;

                //NOTE(Thompson): Setting the renderer to a variable, so I can later on check to see
                //if the renderer is disabled or not. If disabled, disallow unit selection.
                this.selectionBoxRenderer = renderer;
            }

            if (this.unitAttributesManager == null)
            {
                this.unitAttributesManager = GameObject.FindObjectOfType <UnitAttributes>();
                if (this.unitAttributesManager == null)
                {
                    Debug.LogError("Unable to get unit attributes manager.");
                }
            }

            this.selectionBox    = new Rect();
            this.initialClick    = Vector3.one * -9999f;
            this.screenPoint     = this.initialClick;
            this.isGameStart     = false;
            this.isUnitListEmpty = true;
            //NOTE(Thompson): This means you are allowed to merge. This checks if there exists one or more LV1 game unit available.
            this.doNotAllowMerging = false;
            //NOTE(Thompson): NewSpawner needs to keep track of where the first game unit is spawned at. This is set in CmdInitialize().
            this.changes.Clear();

            CmdInitialize(this.gameObject);
        }