示例#1
0
    public override IEnumerator SlowUpdate()
    {
        yield return(new WaitUntil(() => myChar.ready));

        if (myChar.ready)
        {
            //UI stuff is happening locally to each player, score is the only synchronized value that the server sends.
            apCanvas.enabled = false;

            if (IsClient)
            {
                Pname = myChar.Pname;
            }

            if (IsLocalPlayer)
            {
                apCanvas.enabled = true;
                InfectedPanel.SetActive(false);
                manager = myChar.manager;
            }

            while (true)
            {
                if (IsLocalPlayer)
                {
                    apText.text          = "";
                    playerScoreText.text = "";
                    localScoreText.text  = myChar.score.ToString();
                    pnameText.text       = Pname;
                    players = FindObjectsOfType <GameCharacter>();
                    tpRemainingText.text = "TP Left" + "\n" + (manager.maxTurnIn - manager.turnedIn).ToString();
                    tpCarried.text       = "TP Carried: " + myChar.inventory.tpCarried.ToString();
                    if (myChar.inventory.tpCarried >= myChar.inventory.maxCarried)
                    {
                        tpCarried.text += " (max)";
                    }
                    hpBar.value = myChar.health;
                    foreach (GameCharacter player in players)
                    {
                        apText.text          += player.Pname + "\n";
                        playerScoreText.text += player.score + "\n";
                    }
                }

                yield return(new WaitForSeconds(MyCore.MasterTimer));
            }
        }
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     manager = FindObjectOfType <GameManagingScript>();
     cam     = FindObjectOfType <Camera>();
 }
示例#3
0
    public override IEnumerator SlowUpdate()
    {
        //At this point I know everything is initialized and ready to go.
        manager = FindObjectOfType <GameManagingScript>();
        myRig   = this.GetComponent <Rigidbody>();

        if (IsLocalPlayer)
        {
            cam = FindObjectOfType <Camera>();

            cam.transform.position = transform.position + new Vector3(0, 15f, 0);
            cam.transform.LookAt(transform);
        }

        if (IsServer)
        {
            SpawnPoint = manager.spawnObjects[Owner % 4];
        }

        while (true)
        {
            if (!end)
            {
                if (IsServer)
                {
                    //Player dies and respawns at their home. Player loses TP carried. Cures Infection.
                    if (health <= 0 && !dead)
                    {
                        dead = true;
                        SendUpdate("DEAD", true.ToString());
                        StartCoroutine(PlayerDeath());
                    }

                    if (spedUp)
                    {
                        if (Time.time >= speedTime)
                        {
                            speedTime = float.PositiveInfinity;
                            NormalSpeed();
                        }
                    }
                }

                if (IsLocalPlayer)
                {
                    if (((cam.transform.position - transform.position) + new Vector3(0, 12, 0)).magnitude < 21)
                    {
                        //lerp
                        cam.transform.position = Vector3.Lerp(cam.transform.position, transform.position + new Vector3(0, 12, 0), lerpVal);
                    }
                    else
                    {
                        cam.transform.position = transform.position + new Vector3(0, 12, 0);
                    }

                    if (Input.GetAxisRaw("Jump") > 0 && CanShoot)
                    {
                        SendCommand("SHOOT", MyId.NetId.ToString() + ":" + (transform.position + transform.forward).ToString() + ":" + transform.forward.ToString());
                        SendCommand("ATTACK", "1");
                        shoottimer = shootcooldown;
                    }

                    if (shoottimer > 0)
                    {
                        shoottimer -= MyCore.MasterTimer;
                    }
                }
            }

            if (manager.GameEnded)
            {
                end = true;
            }

            if (IsServer)
            {
                if (IsDirty)
                {
                    SendUpdate("PNAME", Pname);
                    SendUpdate("COLOR", color.ToString());
                    IsDirty = false;
                }
            }
            yield return(new WaitForSeconds(MyCore.MasterTimer));
        }
    }
示例#4
0
    public override IEnumerator SlowUpdate()
    {
        manager = FindObjectOfType <GameManagingScript>();
        anim    = this.GetComponent <Animator>();
        int movingHash = Animator.StringToHash("moving");

        //Changing the direction the bad guy is facing based on its initial speed.
        if (speedZ > 0)
        {
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 270, 0));
        }
        else if (speedZ < 0)
        {
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 0));
        }
        else if (speedX < 0)
        {
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 180, 0));
        }

        //Bad guy patrols forward and backwards for a specific amount time.
        while (true)
        {
            if (IsServer && manager.GameStarted && !manager.GameEnded)
            {
                if (routeNumber == 1)
                {
                    transform.position += new Vector3(speedX, 0, speedZ);

                    if (directionTimer > 0)
                    {
                        directionTimer -= MyCore.MasterTimer;
                    }
                    else
                    {
                        speedX *= -1;
                        speedZ *= -1;

                        transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 180, 0));


                        directionTimer = directionReset;
                    }
                }
                else if (routeNumber == 2)
                {
                    transform.position += new Vector3(speedX, 0, speedZ);

                    if (directionTimer > 0)
                    {
                        directionTimer -= MyCore.MasterTimer;
                    }
                    else
                    {
                        //Going left looking at it from the houses direction. Switch directions to go away from houses.
                        if (speedX > 0 && speedZ == 0)
                        {
                            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 0));

                            speedX = 0;
                            speedZ = -.1f;

                            directionTimer = directionLongReset;
                        }
                        else if (speedZ < 0 && speedX == 0)
                        {
                            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 0));

                            speedX = -.1f;
                            speedZ = 0;

                            directionTimer = directionReset;
                        }
                        else if (speedX < 0 && speedZ == 0)
                        {
                            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 0));

                            speedX = 0;
                            speedZ = .1f;

                            directionTimer = directionLongReset;
                        }
                        else if (speedZ > 0 && speedX == 0)
                        {
                            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 0));

                            speedX = .1f;
                            speedZ = 0;

                            directionTimer = directionReset;
                        }
                    }
                }
                else if (routeNumber == 2)
                {
                }
                if (health <= 0)
                {
                    MyCore.NetDestroyObject(this.NetId);
                }
            }

            if (IsClient)
            {
                anim.SetBool(movingHash, true);
            }

            yield return(new WaitForSeconds(MyCore.MasterTimer));
        }
    }