Ejemplo n.º 1
0
    public void OnTriggerEnter(Collider other)
    {
        if (IsServer)
        {
            Transform temp = other.transform.root;

            if (temp.CompareTag("item"))
            {
                otherRecipeScript = temp.GetComponent <RecipeScript>();
                if (otherRecipeScript != null)
                {
                    recipeScript.AddAction("ADD", otherRecipeScript.ingredientName);

                    if (!(hit.collider.name == "coffee" || hit.collider.name == "cup"))
                    {
                        int otherNetId = temp.GetComponent <NetworkID>().NetId;

                        MyCore.NetDestroyObject(otherNetId);
                    }
                    //coffeeStuff.position = Vector3.Lerp(coffeeStuff.position, max.position, 0.01f);
                    SendUpdate("A", "X");
                }
                //Debug.Log("cup on");
            }
            //Debug.Log(temp.name);
        }
    }
Ejemplo n.º 2
0
    /*
     * public void OnTriggerEnter(Collider other)
     * {
     *  if (IsServer)
     *  {
     *      Transform temp = other.transform.root;
     *
     *      if (other.name == "egg")
     *      {
     *          otherRecipeScript = temp.GetComponent<RecipeScript>();
     *          if (otherRecipeScript != null)
     *          {
     *              if (!otherRecipeScript.isBeingHeld)
     *              {
     *                  recipeScript.AddAction("BREAK", otherRecipeScript.ingredientName);
     *
     *                  //if (!(hit.collider.name == "coffee" || hit.collider.name == "cup"))
     *                  //{
     *
     *                  MyCore.NetCreateObject(19, NetId, spawnPos.position); //fryed egg
     *
     *                  int otherNetId = temp.GetComponent<NetworkID>().NetId;
     *
     *                  MyCore.NetDestroyObject(otherNetId);
     *              }
     *
     *              //}
     *
     *          }
     *          //Debug.Log("cup on");
     *      }
     *      //Debug.Log(temp.name);
     *  }
     * }
     */
    public void OnCollisionEnter(Collision other)
    {
        if (IsServer)
        {
            Transform temp = other.collider.transform.root;

            if (temp.name == "egg")
            {
                otherRecipeScript = temp.GetComponent <RecipeScript>();
                if (otherRecipeScript != null)
                {
                    if (!otherRecipeScript.isBeingHeld)
                    {
                        recipeScript.AddAction("BREAK", otherRecipeScript.ingredientName);

                        //if (!(hit.collider.name == "coffee" || hit.collider.name == "cup"))
                        //{

                        MyCore.NetCreateObject(19, NetId, spawnPos.position); //fryed egg

                        int otherNetId = temp.GetComponent <NetworkID>().NetId;

                        MyCore.NetDestroyObject(otherNetId);
                    }

                    //}
                }
                //Debug.Log("cup on");
            }
            //Debug.Log(temp.name);
        }
    }
Ejemplo n.º 3
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            managerScript = GameObject.FindGameObjectWithTag("manager").GetComponent <RecipeManagerScript>();

            submissionHeight = GameObject.FindGameObjectWithTag("sub").transform.position.y;
        }
        if (IsClient)
        {
        }
        while (IsServer)
        {
            if (this.transform.position.y > submissionHeight)
            {
                myParticle.Play();
                myAudio.Play();

                managerScript.RecieveOrder(recipeScript.ToString());

                MyCore.NetDestroyObject(NetId);
                //destroy
            }

            yield return(new WaitForSeconds(0.2f)); //potentially slower
        }
    }
Ejemplo n.º 4
0
    public override IEnumerator SlowUpdate()
    {
        myFlag = this.transform.GetChild(2).GetComponent <Rigidbody>();
        while (true)
        {
            if (IsServer)
            {
                //Send update on flags capture progress
                if (!isCaptured)
                {
                    CaptureTeam();
                }

                //Destroy itself
                else
                {
                    yield return(new WaitForSeconds(.1f));

                    MyCore.NetDestroyObject(this.NetId);
                }
            }

            yield return(new WaitForSeconds(MyCore.MasterTimer));
        }
    }
Ejemplo n.º 5
0
    public void KillPlayer(NetworkPlayerController player)
    {
        SendUpdate("REMOVEWEAPONS", player.Owner.ToString());
        SendUpdate("ARROW", "false");

        //If object is destroyed in capture zone, flag will still be captured
        MyCore.NetDestroyObject(player.NetId);
        StartCoroutine(RespawnPlayer(5, player));
    }
Ejemplo n.º 6
0
    public IEnumerator KillGame()
    {
        yield return(new WaitForSeconds(10));

        PlaneControlScript plane = GameObject.FindObjectOfType <PlaneControlScript>();

        MyCore.NetDestroyObject(plane.NetId);
        MyCore.UI_Quit();
    }
Ejemplo n.º 7
0
 public override void HandleMessage(string flag, string value)
 {
     if (flag == "Destroy")
     {
         if (!IsLocalPlayer)
         {
             MyCore.NetDestroyObject(MyId.NetId);
         }
     }
 }
Ejemplo n.º 8
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Lava")
     {
         MyCore.NetDestroyObject(this.NetId);
     }
     else if (IsServer && switched >= 1)
     {
         switched -= 1;
         GameObject temp = MyCore.NetCreateObject(12 + ItemSpawn, this.Owner, this.transform.position);
         temp.GetComponent <ItemContainer>().IsCrateDrop = true;
         MyCore.NetDestroyObject(this.NetId);
     }
 }
Ejemplo n.º 9
0
    public override IEnumerator SlowUpdate()
    {
        while (true)
        {
            if (IsServer)
            {
                if (health <= 0)
                {
                    MyCore.NetDestroyObject(NetId);
                }
            }

            yield return(new WaitForSeconds(MyCore.MasterTimer));
        }
    }
Ejemplo n.º 10
0
 private void OnTriggerEnter(Collider collision)
 {
     if (IsServer && collision.gameObject.tag == "Player" && IsAvalible)
     {
         IsAvalible = false;
         if (IsWeapon)
         {
             collision.gameObject.GetComponent <NetworkPlayerController>().AddWeapon(ContainedItem.GetComponent <Weapon>().ItemID);
         }
         if (IsCrateDrop)
         {
             MyCore.NetDestroyObject(NetId);
         }
         else
         {
             SendUpdate("USED", "1");
             MyRig.gameObject.SetActive(false);
             StartCoroutine(ItemRespawn(RespawnTimer));
         }
     }
 }
Ejemplo n.º 11
0
 public void ChangeTeam(string team, NetworkPlayerController player, NetworkPlayer playerManager)
 {
     if (team != "GREEN")
     {
         redPlayers++;
         greenPlayers--;
         MyCore.NetDestroyObject(player.NetId);
         playerManager.ModelNum = 11;
     }
     else
     {
         redPlayers--;
         greenPlayers++;
         MyCore.NetDestroyObject(player.NetId);
         playerManager.ModelNum = 10;
     }
     playerManager.SendUpdate("REMOVEWEAPONS", playerManager.Owner.ToString());
     playerManager.SendUpdate("MODEL", playerManager.ModelNum.ToString());
     playerManager.SendUpdate("PNAME", playerManager.PNAME);
     MyCore.NetCreateObject(playerManager.ModelNum, playerManager.Owner, player.transform.position, player.transform.rotation);
 }
Ejemplo n.º 12
0
    public IEnumerator DeathTimer(float time)
    {
        yield return(new WaitForSeconds(time));

        MyCore.NetDestroyObject(this.NetId);
    }
Ejemplo n.º 13
0
    public override void HandleMessage(string flag, string value)
    {
        if (flag == "Name")
        {
            fakeText.text = value;
        }

        if (flag == "Next")
        {
            j = i;

            if (firstTime == true)
            {
                firstTime = false;

                i++;

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform.forward);
                }
            }

            if (firstTime == false)
            {
                MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

                i++;

                if (i >= 9)
                {
                    i = 5;
                    j = 8;
                }

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }
        }

        if (flag == "Previous")
        {
            j = i;

            if (firstTime == true)
            {
                firstTime = false;

                i--;

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(4, 4, 4);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }

            if (firstTime == false)
            {
                MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

                i--;

                if (i <= 4)
                {
                    i = 8;
                    j = 5;
                }

                if (IsServer)
                {
                    temp = MyCore.NetCreateObject(i, 1, new Vector3(0, 0, 0));
                    temp.transform.localScale = new Vector3(5, 5, 5);
                    temp.transform.LookAt(Camera.main.transform);
                }
            }
        }

        if (flag == "Ready")
        {
            count++;

            this.gameObject.SetActive(false);

            MyCore.NetDestroyObject(temp.GetComponent <NetworkID>().NetId);

            switch (i)
            {
            case 5:
                i = 1;
                break;

            case 6:
                i = 2;
                break;

            case 7:
                i = 3;
                break;

            case 8:
                i = 4;
                break;
            }

            if (IsServer)
            {
                temp = MyCore.NetCreateObject(i, 1, spawn);
                temp.transform.GetChild(0).GetComponent <TextMesh>().text = nameText;
                Camera.main.transform.position = new Vector3(743, 1278, -2878);
                Camera.main.transform.Rotate(74, 0, 0);

                foreach (GameObject enemy in enemies)
                {
                    enemy.GetComponent <Bad_Guy_Movement>().enabled = true;
                }
            }
        }
    }
Ejemplo n.º 14
0
    public override void HandleMessage(string flag, string value)
    {
        if (string.CompareOrdinal(flag, "LEFT") == 0)
        {
            isLeft = bool.Parse(value);
        }
        if (string.CompareOrdinal(flag, "RIGHT") == 0)
        {
            isRight = bool.Parse(value);
        }
        if (string.CompareOrdinal(flag, "RAYL") == 0 && !chefScript.dualHold)
        {
            char[]   remove = { '(', ')' };
            string[] data   = value.Trim(remove).Split(',');
            tempRayLeft = new Vector3(
                float.Parse(data[0]),
                float.Parse(data[1]),
                float.Parse(data[2])
                );

            tempProjL = -Vector3.ProjectOnPlane(camTargetLeft.position - tempRayLeft, -camTargetLeft.up) * moveScale;

            if (!chefScript.dualHold)
            {
                leftTarget.position = Vector3.Lerp(leftTarget.position, tempProjL + camTargetLeft.position, 0.5f);
            }

            //leftTarget.position = Vector3.Lerp(leftTarget.position, leftTarget.position + leftTarget.up * handHeightLeft, 0.5f);

            //leftTarget.position = Vector3.Lerp(leftTarget.position, leftTarget.position + leftTarget.up * handHeightLeft, 0.5f);
        }
        if (string.CompareOrdinal(flag, "RAYR") == 0)
        {
            char[]   remove = { '(', ')' };
            string[] data   = value.Trim(remove).Split(',');
            tempRayRight = new Vector3(
                float.Parse(data[0]),
                float.Parse(data[1]),
                float.Parse(data[2])
                );

            tempProjR = -Vector3.ProjectOnPlane(camTargetRight.position - tempRayRight, -camTargetRight.up) * moveScale;

            if (!chefScript.dualHold)
            {
                rightTarget.position = Vector3.Lerp(rightTarget.position, tempProjR + camTargetRight.position, 0.5f);
            }
        }

        if (string.CompareOrdinal(flag, "UPL") == 0)
        {
            handHeightLeft         = float.Parse(value);
            leftTarget.position    = Vector3.Lerp(leftTarget.position, leftTarget.position + leftTarget.up * handHeightLeft, 0.5f);
            camTargetLeft.position = Vector3.Lerp(camTargetLeft.position, camTargetLeft.position + camTargetLeft.up * handHeightLeft, 0.5f);
        }
        if (string.CompareOrdinal(flag, "UPR") == 0)
        {
            handHeightRight         = float.Parse(value);
            rightTarget.position    = Vector3.Lerp(rightTarget.position, rightTarget.position + rightTarget.up * handHeightRight, 0.5f);
            camTargetRight.position = Vector3.Lerp(camTargetRight.position, camTargetRight.position + camTargetRight.up * handHeightRight, 0.5f);
        }
        if (string.CompareOrdinal(flag, "CAMPOS") == 0)
        {
            char[]   remove = { '(', ')' };
            string[] data   = value.Trim(remove).Split(',');
            camPositionClient = new Vector3(
                float.Parse(data[0]),
                float.Parse(data[1]),
                float.Parse(data[2])
                );
        }
        if (string.CompareOrdinal(flag, "CAMTAR") == 0)
        {
            char[]   remove = { '(', ')' };
            string[] data   = value.Trim(remove).Split(',');
            camTargetClient = new Vector3(
                float.Parse(data[0]),
                float.Parse(data[1]),
                float.Parse(data[2])
                );
        }

        if (string.CompareOrdinal(flag, "HL") == 0)
        {
            leftIsHold = bool.Parse(value);
            if (leftIsHold)
            {
                chefScript.HoldLeft();
            }
            else
            {
                chefScript.LeftLetGo();
            }
        }
        if (string.CompareOrdinal(flag, "HR") == 0)
        {
            rightIsHold = bool.Parse(value);
            if (rightIsHold)
            {
                chefScript.HoldRight();
            }
            else
            {
                chefScript.RightLetGo();

                //Debug.Log("letting go");
            }
        }
        if (string.CompareOrdinal(flag, "DEST") == 0)
        {
            MyCore.NetDestroyObject(int.Parse(value));
        }

        //turning later

        /*
         * if(string.CompareOrdinal(flag, "TL") == 0)
         * {
         *  chefScript.TurnLeft(bool.Parse(value));
         * }
         */
    }
Ejemplo n.º 15
0
    public IEnumerator Despawn(int time)
    {
        yield return(new WaitForSeconds(time));

        MyCore.NetDestroyObject(NetId);
    }
Ejemplo n.º 16
0
    //Collisions

    //Triggers
    private void OnTriggerEnter(Collider other)
    {
        if (IsServer)
        {
            if (other.CompareTag("enemy"))
            {
                SetHealth(0);
            }

            if (other.CompareTag("TP"))
            {
                if (inventory.tpCarried < inventory.maxCarried)
                {
                    SetTPCarried(inventory.tpCarried + 1);
                    MyCore.NetDestroyObject(other.GetComponent <NetworkID>().NetId);
                }
            }

            if (other.CompareTag("GoldenTP"))
            {
                SetTPCarried(inventory.tpCarried + 3);
                MyCore.NetDestroyObject(other.GetComponent <NetworkID>().NetId);
            }

            if (other.CompareTag("House"))
            {
                if (inventory.tpCarried > 0)
                {
                    SetScore(score + inventory.tpCarried);
                    manager.playerTurnedIn(inventory.tpCarried);
                    SetTPCarried(0);
                }
            }

            if (other.CompareTag("HealingPad"))
            {
                healing = true;
                if (isInfected)
                {
                    CureInfection();
                }
                StartCoroutine(HealingOverTime());
                SendUpdate("HEALING", true.ToString());
            }

            if (other.CompareTag("radius"))
            {
                //Making sure the player isn't already infected and that the radius hit is not your own.
                GameObject colObj = other.transform.parent.gameObject;
                if (!isInfected && colObj != this.transform.gameObject)
                {
                    Debug.Log("TOO CLOSE, YOU'RE INFECTED NOW");

                    //See if they are an enemy or player
                    if (colObj.CompareTag("enemy"))
                    {
                        Debug.Log("Enemy infected you");
                        Infect();
                    }
                    if (colObj.CompareTag("Player"))
                    {
                        if (colObj.GetComponent <GameCharacter>().isInfected)
                        {
                            Debug.Log("Player infected you");
                            Infect();
                        }
                    }
                }
            }

            if (other.CompareTag("SpeedDrink"))
            {
                if (spedUp == false)
                {
                    MyCore.NetDestroyObject(other.GetComponent <NetworkID>().NetId);
                    IncreaseSpeed();
                }
            }

            if (other.CompareTag("Medicine"))
            {
                if (isInfected == true)
                {
                    CureInfection();
                }
            }
        }

        if (IsClient)
        {
            if (other.CompareTag("Finish"))
            {
                //play sound effect
            }
        }
    }
Ejemplo n.º 17
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));
        }
    }