Beispiel #1
0
 protected void Rush(World.Direction d)
 {
     // if d != faceDir => doge (not move, just skip attack)
     // if d == faceDir => rush
     ((RushAction)actionTable [Action.Type.Rush]).SetDirection(d);
     actionTable [Action.Type.Rush].TriggerAction();
 }
Beispiel #2
0
 public void Climb(World.Direction d)
 {
     ((ClimbAction)actionTable [Action.Type.Climb]).SetDirection(d);
     if (((ClimbAction)actionTable[Action.Type.Climb]).ClimbableFound())
     {
         if (!isClimbing)
         {
             actionTable [Action.Type.Climb].TriggerAction();
         }
     }
 }
Beispiel #3
0
    public void Turn(World.Direction d)
    {
        if (canTurn && faceDir != (int)d)
        {
            faceDir = (int)d;
            Vector3 newScale = transform.localScale;
            newScale.x = -faceDir *Mathf.Abs(newScale.x);

            transform.localScale = newScale;
        }
    }
Beispiel #4
0
 void Rotate(int angle, float posX, float posZ)
 {
     if (angle == 90)
     {
         bikeDir = (World.Direction)(((int)bikeDir + 1) % 4);
     }
     else if (angle == -90)
     {
         bikeDir = (World.Direction)(((int)bikeDir + 3) % 4);
     }
     updateVelocity();
 }
Beispiel #5
0
 public void SetDirection(World.Direction d)
 {
     direction = (int)d;
     if (d == World.Direction.UP)
     {
         colli     = colliUp;
         climbArea = climbAreaUp;
     }
     else if (d == World.Direction.DOWN)
     {
         colli     = colliDown;
         climbArea = climbAreaDown;
     }
 }
Beispiel #6
0
 // Use this for initialization
 void Start()
 {
     bikeDir    = World.Direction.North;
     nextDir    = World.Direction.North;
     bike       = GetComponent <Rigidbody>();
     bikeSpeed  = 0;
     zVel       = 0;
     xVel       = 0;
     justTurned = false;
     helpOn     = true;
     resetPlayer();
     pedestrianCrash       = false;
     nextDir               = W.resetWorld();
     bloodSplatter.enabled = false;
 }
Beispiel #7
0
 void resetGame()
 {
     bikeDir            = World.Direction.North;
     nextDir            = World.Direction.North;
     transform.position = new Vector3(0, 0, 0);
     transform.rotation = Quaternion.Euler(0, 0, 0);
     bike.position      = new Vector3(0, 0, 0);
     bike.rotation      = Quaternion.Euler(0, 0, 0);
     bikeSpeed          = 0;
     zVel            = 0;
     xVel            = 0;
     justTurned      = false;
     helpOn          = true;
     pedestrianCrash = false;
     resetPlayer();
     nextDir = W.resetWorld();
 }
Beispiel #8
0
 // ==== control ==============
 public void Move(World.Direction d)
 {
     if (World.Direction.STOP == d)
     {
         moveSpeed = 0;
         isMoving  = false;
     }
     // if cannot turn, then cannot move to another direction
     else if (!canTurn && faceDir != (int)d)
     {
         moveSpeed = 0;
         isMoving  = false;
     }
     else
     {
         moveSpeed = info.moveSpeed;
         isMoving  = true;
     }
 }
Beispiel #9
0
 public void SetDirection(World.Direction d)
 {
     direction = (int)d;
 }
Beispiel #10
0
    void Update()
    {
        if (!Game.Active)
        {
            return;
        }

        if (camOp.FirstPerson)
        {
            if (!robotForm.activeSelf)
            {
                robotForm.SetActive(true);
            }
        }
        else if (robotForm.activeSelf)
        {
            robotForm.SetActive(false);
            boostEffect.SetActive(true);             // strange bug makes the ball roll funny if this isn't toggled!
        }

        // Get input force
        Vector2 input = GameInput.Movement;

        // Get flags for current actions
        boosting = GameInput.Boosting;
        jumping  = GameInput.Jumping;
        create   = GameInput.CreateBlock;
        pound    = GameInput.GroundPound;

        // calculate camera relative direction to move:
        camForward = Vector3.Scale(cam.forward, new Vector3(1, 0, 1)).normalized;
        Vector3 cameraY = input.y * camForward;
        Vector3 cameraX = input.x * cam.right;

        move = (cameraY + cameraX).normalized;
        Vector3 worldMove = cam.TransformDirection(move);

        //Game.Log("X: " + worldMove.x + "  Y: " + worldMove.z);

        Debug.DrawRay(transform.position, move, Color.cyan, 0.1f);

        // stop bumping up against blocks and jiggling around due to physics
        if (camOp.FirstPerson)
        {
            World3 blockPos = World.GetBlockPosition(Game.Player.transform.position + move);
            ushort block    = World.GetBlock(blockPos);

            if (block != Block.Air)
            {
                World.Direction direction = World.GetDirection(World.GetBlockPosition(Game.Player.transform.position), blockPos);
                if (direction != lastDirection)
                {
                    prevDirection = lastDirection;
                }
                lastDirection = direction;
                Game.Log(direction.ToString());

                Vector3 projectRight   = Vector3.Project(move, Vector3.right);
                Vector3 projectForward = Vector3.Project(move, Vector3.forward);

                Debug.DrawRay(transform.position, projectRight.normalized, Color.red, 0.1f);
                Debug.DrawRay(transform.position, projectForward.normalized, Color.yellow, 0.1f);

                //if (worldMove.z > 0)
                if
                (
                    worldMove.z > 0 ||
                    direction == World.Direction.north ||
                    direction == World.Direction.south
                )
                {
                    block = World.GetBlock(World.GetBlockPosition(Game.Player.transform.position + projectRight.normalized));
                    if (block == Block.Air)
                    {
                        move = projectRight;
                    }
                    else
                    {
                        move = Vector3.zero;
                    }
                }
                else if
                (
                    worldMove.z < 0 ||
                    direction == World.Direction.east ||
                    direction == World.Direction.west
                )
                {
                    block = World.GetBlock(World.GetBlockPosition(Game.Player.transform.position + projectForward.normalized));
                    if (block == Block.Air)
                    {
                        move = projectForward;
                    }
                    else
                    {
                        move = Vector3.zero;
                    }
                }
                else
                {
                    move = Vector3.zero;
                }
            }
        }


        if (create)
        {
            roller.CreateBlocks();
        }

        // TODO: Centralize all input handling
        if (Input.GetKey(KeyCode.Y))
        {
            roller.CreateSphere();
        }

        if (GameInput.SwapInputs)
        {
            Config.SwapInputs = !Config.SwapInputs;
        }

        bool boostOn = roller.GetAfterburnerState();

        if (!camOp.FirstPerson && camOp.Distance > 2f)
        {
            boostEffect.SetActive(boostOn);
        }
        else
        {
            boostEffect.SetActive(false);
        }
        if ((int)Config.QualityLevel >= 2)
        {
            if (boostOn && !camOp.FirstPerson)
            {
                boostLight.intensity = 1f;
            }
            else
            {
                boostLight.intensity = 0f;
            }
        }

        // bash blocks
        if (!create && (boosting || pound))
        {
            Vector3 planePos      = new Vector3(transform.position.x, 0, transform.position.z);
            Vector3 planeLastPos  = new Vector3(lastPosition.x, 0, lastPosition.z);
            Vector3 forwardNormal = Vector3.Normalize(planePos - planeLastPos);
            float   speed         = Mathf.Abs(Vector3.Distance(transform.position, lastPosition));

            roller.BashBlocks(forwardNormal, speed, boosting, jumping, camOp.FirstPerson);
        }
    }
Beispiel #11
0
 public Direction(World.Direction value) => Value = value;
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        bike.velocity = new Vector3(xVel, 0, zVel);
        bikePosition  = bike.position;

        updateVelocity();
        updateLean();

        if (W.score - lastScore > 150)
        {
            velocityScale = (float)(1 + W.score * 0.005);
            lastScore     = W.score;
            W.levelUp();
        }



        if (bikeDir == World.Direction.North)
        {
            xVel = horizVel;
        }
        else if (bikeDir == World.Direction.South)
        {
            xVel = -horizVel;
        }
        else if (bikeDir == World.Direction.East)
        {
            zVel = -horizVel;
        }
        else if (bikeDir == World.Direction.West)
        {
            zVel = horizVel;
        }

        if (SocketClient.signalString == "right")
        {
            rightPlayer.enabled  = true;
            staticPlayer.enabled = false;
            leftPlayer.enabled   = false;
            TimerScript.startTimer(3f, 1);
        }
        else if (SocketClient.signalString == "left")
        {
            rightPlayer.enabled  = false;
            staticPlayer.enabled = false;
            leftPlayer.enabled   = true;
            TimerScript.startTimer(3f, 0);
        }
        else if (SocketClient.signalString == "none")
        {
            rightPlayer.enabled  = false;
            staticPlayer.enabled = true;
            leftPlayer.enabled   = false;
        }
        else if (Input.GetKeyDown(keyT))   // right
        {
            rightPlayer.enabled  = true;
            staticPlayer.enabled = false;
            leftPlayer.enabled   = false;
            TimerScript.startTimer(3f, 1);
        }
        else if (Input.GetKeyDown(keyR))   // middle
        {
            rightPlayer.enabled  = false;
            staticPlayer.enabled = true;
            leftPlayer.enabled   = false;
        }
        else if (Input.GetKeyDown(keyE))   // left
        {
            rightPlayer.enabled  = false;
            staticPlayer.enabled = false;
            leftPlayer.enabled   = true;
            TimerScript.startTimer(3f, 0);
        }

        if (keyBoardMode == true)
        {
            if (Input.GetKeyDown(arrowL) && (controlLocked == "n"))
            {
                horizVel = -5;
                StartCoroutine(stopSlide());
                laneNum      -= 1;
                controlLocked = "y";
                resetPlayer();
            }
            else if (Input.GetKeyDown(arrowR) && (controlLocked == "n"))
            {
                horizVel = 5;
                StartCoroutine(stopSlide());
                laneNum      += 1;
                controlLocked = "y";
                resetPlayer();
            }
        }
        if (SocketClientVoice.turn == "L" && lastTurnNumberLeft < SocketClientVoice.turnNumber)
        {
            TimerScript.startTimer(2f, 2);
            Debug.Log("registered: on your left");
            lastTurnNumberLeft = SocketClientVoice.turnNumber;
        }
        else if (SocketClientVoice.turn == "R" && lastTurnNumberRight < SocketClientVoice.turnNumber)
        {
            TimerScript.startTimer(2f, 3);
            Debug.Log("registered: on your right");
            lastTurnNumberRight = SocketClientVoice.turnNumber;
        }

        if (Input.GetKeyDown(keyZ))  // on your left
        {
            TimerScript.startTimer(4f, 2);
            Debug.Log("on your left");
        }
        else if (Input.GetKeyDown(keyC))   // on your right
        {
            TimerScript.startTimer(4f, 3);
            Debug.Log("on your right");
        }

        if (Input.GetKeyDown(keyW))
        {
            bikeSpeed = bikeSpeed + 2;
            updateVelocity();
        }
        if (Input.GetKeyDown(keyS))
        {
            bikeSpeed = bikeSpeed - 2;
            updateVelocity();
            //resetGame();
        }
        if (Input.GetKeyDown(keyD)) // turn right
        {
            if (TimerScript.turningAllowed == "right")
            {
                Rotate(90, bikePosition.x, bikePosition.z);
                StartCoroutine(RotateCam(Vector3.up, 90, 0.3f));
                TimerScript.stopTimer();
                laneNum = 2;
                resetPlayer();
                TimerScript.stopTimer();
            }
            else
            {
                endGame(2);
            }
        }
        if (Input.GetKeyDown(keyA)) // turn left
        {
            if (TimerScript.turningAllowed == "left")
            {
                Rotate(-90, bikePosition.x, bikePosition.z);
                StartCoroutine(RotateCam(Vector3.up, -90, 0.3f));
                TimerScript.stopTimer();
                laneNum = 2;
                resetPlayer();
                TimerScript.stopTimer();
            }
            else
            {
                endGame(2);
            }
        }

        if (Input.GetKeyDown(keyQ))
        {
            Time.timeScale = 1;
            resetGame();
        }
        // each time you go past the next endpoint, increment streetPieceCounter
        checkCrash();


        if (W.destroyScene(bikePosition.x, bikePosition.z))
        {
            nextDir = W.createScene(nextDir);
        }
    }
Beispiel #13
0
        public override void Run(List <string> givenArguments, Server server)
        {
            // ARGS: <direction>

            // If dead
            if (sender.specialProperties["isDeceased"] == "TRUE")
            {
                RPCs.RPCSay failure = new RPCs.RPCSay();
                failure.arguments.Add("You are deceased.");
                server.SendRPC(failure, nameOfSender);
                return;
            }

            // Make sure the direction is correct
            if (World.Direction.StringToDirection(givenArguments[0]) == null)
            {
                RPCs.RPCSay newRPC = new RPCs.RPCSay();
                newRPC.arguments.Add("Invalid direction.  north | northeast | east...");
                server.SendRPC(newRPC, nameOfSender);
                return;
            }
            // Make sure the player is standing up
            if (sender.specialProperties["stance"] != "STANDING")
            {
                RPCs.RPCSay newRPC = new RPCs.RPCSay();
                newRPC.arguments.Add("You must be standing to go in a direction.");
                server.SendRPC(newRPC, nameOfSender);
                return;
            }
            // Get the direction that the player wants to go
            World.Direction desiredDirection = World.Direction.StringToDirection(givenArguments[0]);
            // Notify everyone in the current chunk that we left
            foreach (World.GameObject gameObject in server.world.GetChunkOrGenerate(sender.position).children)
            {
                if (gameObject.specialProperties.ContainsKey("isPlayer") && gameObject.identifier.name != sender.identifier.name)
                {
                    // Send a message to this player saying that we left the chunk
                    RPCs.RPCSay newRPC = new RPCs.RPCSay();
                    newRPC.arguments.Add(nameOfSender + " went " + givenArguments[0] + ".");
                    server.SendRPC(newRPC, gameObject.identifier.name);
                }
            }
            // Tell the player in the present tense that they are completing the action
            string presentTenseConfirmationString = "You are going " + givenArguments[0] + "...";

            RPCs.RPCSay presentTenseConfirmation = new RPCs.RPCSay();
            presentTenseConfirmation.arguments.Add(presentTenseConfirmationString);
            server.SendRPC(presentTenseConfirmation, nameOfSender);
            // Loop the elipsis three times and send it to the player, implying work being done
            for (int i = 0; i < 1; i++)
            {
                Thread.Sleep(1000);
                RPCs.RPCSay elipsis = new RPCs.RPCSay();
                elipsis.arguments.Add("...");
                server.SendRPC(elipsis, nameOfSender);
            }
            // Move the player in the desired direction
            server.world.MovePlayer(nameOfSender, new World.Position(sender.position.x + desiredDirection.x, sender.position.y + desiredDirection.y, sender.position.z + desiredDirection.z));
            // Notify everyone in the chunk we just arrived at that we have come
            foreach (World.GameObject gameObject in server.world.GetChunkOrGenerate(sender.position).children)
            {
                if (gameObject.specialProperties.ContainsKey("isPlayer") && gameObject.identifier.name != sender.identifier.name)
                {
                    // Send a message to this player saying that we left the chunk
                    RPCs.RPCSay newRPC = new RPCs.RPCSay();
                    newRPC.arguments.Add(nameOfSender + " came from the " + World.Direction.DirectionToString(World.Direction.GetOpposite(desiredDirection)) + ".");
                    server.SendRPC(newRPC, gameObject.identifier.name);
                }
            }
            // Send a look command

            // Describe the current chunk that the sender is on
            string description = Processing.Describer.Describe(server.world.GetChunkOrGenerate(sender.position), sender);

            // Send this new string back to the sender
            RPCs.RPCSay lookRPC = new RPCs.RPCSay();
            lookRPC.arguments.Add(description);
            server.SendRPC(lookRPC, nameOfSender);
        }
Beispiel #14
0
 public void setDirection(World.Direction d)
 {
     dir = d;
 }
Beispiel #15
0
 protected void MoveAimY(World.Direction y)
 {
     aimMoveSpeedY = info.moveSpeed * (int)y;
 }
Beispiel #16
0
 protected void MoveAimX(World.Direction x)
 {
     aimMoveSpeedX = info.moveSpeed * (int)x;
 }