Exemple #1
0
 public ObstaclePayload(Obstacle obstacle, bool successful, TrainMove move, Transform moveCue)
 {
     Obstacle   = obstacle;
     Successful = successful;
     Move       = move;
     MoveCue    = moveCue;
 }
Exemple #2
0
        private void TransitionWithMove(TrainMove move, TrainState state, bool immediate = false)
        {
            var obstacle = Obstacle.HandleMovePressed(move);

            var moveCue = GetMoveCue(obstacle, immediate);

            TrainController.TransitionState(state, moveCue);
        }
Exemple #3
0
 private void Awake()
 {
     minX         = LDoor.transform.position.x;
     maxX         = RDoor.transform.position.x;
     m_Character  = FindObjectOfType <TransformForce>();
     m_TrainMove  = FindObjectOfType <TrainMove>();
     Running      = transform.Find("Running").GetComponent <AudioSource>();
     DoorAudio    = transform.Find("DoorAudio").GetComponent <AudioSource>();
     stationIndex = -1;
     //nowNPC = new List<NPC>();
 }
Exemple #4
0
        private bool HandleMoveHold(TrainMove move, TrainState stateOnRelease)
        {
            var playerReleased = TrainMoves.GetKeyRelease(move);

            if (playerReleased)
            {
                TrainController.TransitionState(stateOnRelease, null);
            }

            return(playerReleased);
        }
Exemple #5
0
        // protected bool HandleHonk()
        // {
        //     var honk = TrainMoves.GetKeyDown(TrainMove.Honk);
        //     if (!honk) return false;
        //
        //     TrainController.Instance.HonkAnim();
        //     var obstacle = Obstacle.HandleMovePressed(TrainMove.Honk);
        //     return obstacle != null;
        // }


        private bool HandleMoveTransition(TrainMove move, TrainState state, bool immediate = false)
        {
            var playerPressed = TrainMoves.GetKeyDown(move);

            if (playerPressed)
            {
                TransitionWithMove(move, state, immediate);
            }

            return(playerPressed);
        }
    void Update()
    {
        //To detect if clicked outside
        if (rigidBody != null && !isPressed && Input.GetMouseButtonDown(0) && (new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y) - new Vector2(transform.position.x, transform.position.y)).magnitude > 1 && (transform.position - rigidBody.transform.position).magnitude < 0.5f && Time.time - timebwclicks > 0.5f)
        {
            Debug.Log("called");
            timebwclicks = Time.time;
            Debug.Log("asdasd0");
            rigidBody.drag        = 19.71f;
            rigidBody.angularDrag = 4.25f;
            isPressed             = false;
            GetComponent <FollowedBy>().followedby           = null;
            rigidBody.GetComponent <SpringJoint2D>().enabled = false;
            rigidBody.isKinematic = false;
            TrainMove.ExtendTrain(rigidBody.GetComponent <FollowedBy>());
            hasHoveringBlob = false;

            rigidBody.GetComponent <BlobHandler>().held = false;
            rigidBody = null;
        }

        /*    if(rigidBody!=null && TrainMove.PartOfTrain(rigidBody.GetComponentInChildren<FollowedBy>()))
         *  {
         *      rigidBody.drag = 19.71f;
         *      rigidBody.angularDrag = 4.25f;
         *      isPressed = false;
         *      rigidBody.GetComponent<SpringJoint2D>().enabled = false;
         *      rigidBody.isKinematic = false;
         *      TrainMove.ExtendTrain(rigidBody.GetComponent<FollowedBy>());
         *      hasHoveringBlob = false;
         *      GetComponent<FollowedBy>().followedby = null;
         *      rigidBody.GetComponent<BlobHandler>().held = false;
         *      rigidBody = null;
         *  }*/

        if (isPressed)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (Vector3.Distance(mousePos, hook.position) > maxDragDistance)
            {
                rigidBody.position = hook.position + (mousePos - hook.position).normalized * maxDragDistance;
            }
            else
            {
                rigidBody.position = mousePos;
            }



            //Debug.Log(rigidBody.GetComponent<SpringJoint2D>().breakForce);
        }
    }
 private bool AddTrain(GameObject link)
 {
     print(link);
     if (link.tag == "Train")
     {
         train = link.GetComponent <TrainMove>();
     }
     else
     {
         train = link.GetComponent <TruckMove>().GetTrain();
     }
     return(true);
 }
    public void Clicked()
    {
        if (!held)
        {
            TrainMove.RemoveCarriage(GetComponent <FollowedBy>());
            Debug.Log("CLICKED");
            Rigidbody2D rigid = GetComponent <Rigidbody2D>();
            rigid.drag        = 10;
            rigid.angularDrag = 3;



            playerShooter.SetRigidBody(rigidBody);
        }
    }
Exemple #9
0
        /// <summary>
        /// Returns true if was in an obstacle zone
        /// </summary>
        public static Obstacle HandleMovePressed(TrainMove move)
        {
            var obstacles = CurrObstacles[move];
            var obs       = obstacles.FirstOrDefault();

            Assert.IsTrue(obstacles.Count <= 1, "More than one obstacle should not overlap!");
            if (!obs)
            {
                return(null);
            }

            obs.OnPressedInZone();

            return(obs);
        }
    // Start is called before the first frame update
    void Start()
    {
        isFinished  = false;
        GameManager = GameObject.FindGameObjectWithTag("GameManager");

        TheSpotWhereTheRailMountedPassengerCarryingApparatusBeginsItsJourneyForWonderAndDiscovery = GameObject.FindGameObjectWithTag("TrainCreationLocation");
        transform.position = TheSpotWhereTheRailMountedPassengerCarryingApparatusBeginsItsJourneyForWonderAndDiscovery.transform.position;
        EntranceNodes      = GameObject.FindGameObjectsWithTag("EntranceNode");
        trainMove          = GetComponent <TrainMove>();
        EntranceToPick     = Random.Range(0, EntranceNodes.Length);
        trainMove.SetCurrentNode(EntranceNodes[EntranceToPick]);
        trainMove.SetNextNode(EntranceNodes[EntranceToPick]);

        int colorID;

        if (EntranceNodes[EntranceToPick].GetComponent <NodeManager>().colorID == 3)
        {
            colorID = Random.Range(0, 3);
        }
        else
        {
            colorID = Random.Range(0, 4);
        }


        switch (colorID)
        {
        case 0:
            color = "yellow";
            gameObject.GetComponent <SpriteRenderer>().color = Color.yellow;
            break;

        case 1:
            color = "blue";
            gameObject.GetComponent <SpriteRenderer>().color = Color.blue;
            break;

        case 2:
            color = "red";
            gameObject.GetComponent <SpriteRenderer>().color = Color.red;
            break;

        case 3:
            color = "green";
            gameObject.GetComponent <SpriteRenderer>().color = Color.green;
            break;
        }
    }
        private GameObject GetObstaclePrefab(TrainMove move)
        {
            switch (move)
            {
            case TrainMove.Jump:
                return(jumpObstaclePrefab);

            case TrainMove.Duck:
                return(duckObstaclePrefab);

            case TrainMove.Honk:
                return(honkObstaclePrefab);

            default:
                throw new ArgumentOutOfRangeException(nameof(move), move, null);
            }
        }
        protected override void ComputeVelocity()
        {
            if (jump && IsGrounded)
            {
                velocity.y = jumpTakeOffSpeed * model.jumpModifier;
                jump       = false;
            }
            else if (stopJump)
            {
                stopJump = false;
                if (velocity.y > 0)
                {
                    velocity.y = velocity.y * model.jumpDeceleration;
                }
            }

            if (move.x > 0.01f)
            {
                spriteRenderer.flipX = false;
                if (flipBool != false)
                {
                    TrainMove.flip();
                }
                flipBool = false;
                followObject.transform.localPosition = new Vector3(-1 * initpos.x, initpos.y, initpos.z);
            }
            else if (move.x < -0.01f)
            {
                spriteRenderer.flipX = true;
                if (flipBool != true)
                {
                    TrainMove.flip();
                }
                flipBool = true;
                followObject.transform.localPosition = 1 * initpos;
            }

            animator.SetBool("grounded", IsGrounded);
            animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed);

            targetVelocity = move * maxSpeed;
        }
Exemple #13
0
        public void PlaySFX(TrainMove move)
        {
            switch (move)
            {
            case TrainMove.Jump:
                Jump.PlayRandom();
                break;

            case TrainMove.Duck:
                Duck.PlayRandom();
                break;

            case TrainMove.Honk:
                Honk.PlayRandom();
                break;

            case TrainMove.DuckEnd:
                DuckEnd.PlayRandom();
                break;
            }
        }
    public void SetRigidBody(Rigidbody2D rb)
    {
        if (rigidBody != null)
        {
            rigidBody.drag        = 19.71f;
            rigidBody.angularDrag = 4.25f;
            isPressed             = false;
            rigidBody.GetComponent <SpringJoint2D>().enabled = false;
            rigidBody.isKinematic = false;
            TrainMove.ExtendTrain(rigidBody.GetComponent <FollowedBy>());
            hasHoveringBlob = false;
            GetComponent <FollowedBy>().followedby      = null;
            rigidBody.GetComponent <BlobHandler>().held = false;
            rigidBody = null;
        }

        GetComponent <FollowedBy>().followedby = rb.GetComponent <FollowedBy>();
        rigidBody = rb;
        /*   rigidBody.transform.SetParent(gameObject.transform,true);*/
        hasHoveringBlob = true;
        rigidBody.GetComponent <BlobHandler>().held = true;
    }
 protected override void OnEnable()
 {
     base.OnEnable();
     TrainMove.ExtendTrain(followObject.GetComponent <FollowedBy>());
 }
Exemple #16
0
        private void TransitionWithMove(TrainMove move, TrainState state)
        {
            var obstacle = Obstacle.HandleMovePressed(move);

            TrainController.TransitionState(state, obstacle ? obstacle.MoveCue : null);
        }
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "BabyBlob")
            {
                int temp = other.GetComponent <BabyBlobHandler>().id;
                switch (temp)
                {
                case 0:
                    stickyBabyCount++;
                    if (stickyBabyCount >= maxBabyCount)
                    {
                        stickyBabyCount = 0;
                        GameObject go = Instantiate(stickyBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;

                case 1:
                    fireBabyCount++;
                    if (fireBabyCount >= maxBabyCount)
                    {
                        fireBabyCount = 0;
                        GameObject go = Instantiate(fireBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;

                default:
                    waterBabyCount++;
                    if (waterBabyCount >= maxBabyCount)
                    {
                        waterBabyCount = 0;
                        GameObject go = Instantiate(waterBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;
                }

                Destroy(other.gameObject);
            }
        }
Exemple #18
0
 // Start is called before the first frame update
 void Start()
 {
     audioSource = GetComponent <AudioSource>();
     // oculusSpatialiser = GetComponent<ONSPAudioSource>();
     train = GameObject.Find("TrainControl").GetComponent <TrainMove>();
 }
Exemple #19
0
        public static bool GetKeyRelease(TrainMove move)
        {
            var keys = _keyDict[move];

            return(keys.All(key => !Input.GetKey(key)));
        }
Exemple #20
0
        public static bool GetKeyHold(TrainMove move)
        {
            var keys = _keyDict[move];

            return(keys.Any(Input.GetKey));
        }
 public ObstacleData(TrainMove move, int beat)
 {
     this.Move = move;
     this.Beat = beat;
 }
 public void Add()
 {
     TrainMove.ExtendTrain(this);
 }