Example #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        Zipline zipline = (Zipline)target;

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Look At Start"))
        {
            zipline.LookAtStart();
        }

        if (GUILayout.Button("Look At End"))
        {
            zipline.LookAtEnd();
        }

        if (GUILayout.Button("Fix Carrier Rotation"))
        {
            zipline.FixCarrierRotation();
        }

        GUILayout.EndHorizontal();
    }
Example #2
0
 //Reset all state when this module gets initialized
 protected override void ResetState()
 {
     base.ResetState();
     m_LastZiplineClimbTime = 0.0f;
     m_IsSkating            = false;
     m_CurrentZipline       = null;
 }
Example #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //somente o filho "Ghost" consegue entrar em contato com "Enemy"s
        if (collision.transform.CompareTag("Enemy"))
        {
            IStompable enemy = collision.transform.GetComponent <IStompable>();
            if (enemy != null)
            {
                if ((transform.position - collision.transform.position).y > enemy.GetYStompRange())
                {
                    enemy.OnStompEvent(this);
                }
                else
                {
                    enemy.OnTouchEvent(this);
                }
            }
        }
        else if (collision.CompareTag("Zipline"))
        {
            Zipline zipline = collision.GetComponent <Zipline>();
            if (zipline && !zipline.Disabled)
            {
                Vector3 snap = zipline.SnapedPosition(transform.position);
                snap -= transform.position;
                if (snap.magnitude < 1f)
                {
                    transform.position += snap;
                    SetZippingState(zipline);
                }
            }
        }
        else if (collision.transform.CompareTag("Hitbox") || collision.transform.CompareTag("Explosion"))
        {
            Hitbox hitbox = collision.GetComponent <Hitbox>();
            if (hitbox && hitbox.id != ID.Player)
            {
                SetDamage(collision.transform.position, hitbox.damage);
            }
        }
        else if (collision.CompareTag("Blastzone"))
        {
            controller.Die();
        }
        else if (collision.CompareTag("Exit"))
        {
            Window windowScript = collision.GetComponent <Window>();
            if (windowScript)
            {
                groundMovement.enabled = airborneMovement.enabled = zippingMovement.enabled = false;
                GetComponent <Collider2D>().enabled = false;

                m_animator.SetBool("Airborne", true);
                m_animator.SetFloat("HorizontalSpeed", 0f);
                m_animator.SetTrigger("Reset");

                controller.TravelThroughExit(collision.transform.position, windowScript);
            }
        }
    }
Example #4
0
    //Character needs to be touching a Zipline object
    public override bool IsApplicable()
    {
        if (!m_IsActive && ((Time.time - m_LastZiplineClimbTime < m_ZiplineClimbCoolDown) || m_ControlledCollider.GetVelocity().y > 0.0f))
        {
            return(false);
        }
        if (m_CanReleaseZiplineWithInput)
        {
            if ((DoesInputExist("ClimbRelease") && GetButtonInput("ClimbRelease").m_IsPressed) ||
                GetDirInput("Move").m_Direction == DirectionInput.Direction.Down)
            {
                return(false);
            }
        }
        if (m_ControlledCollider.IsGrounded())
        {
            return(false);
        }
        Zipline zipline = null;

        if (m_IsActive)
        {
            zipline = m_CurrentZipline;
        }
        else
        {
            zipline = FindZipline();
        }
        if (zipline)
        {
            if (!m_IsActive)
            {
                m_IsSkating = zipline.IsSkateLine();
                Vector3 newPoint = zipline.GetClosestPointOnZipline(GetAttachPoint());

                Vector3 diff = newPoint - GetAttachPoint();
                if (m_ControlledCollider.GetCapsuleTransform().CanMove(diff))
                {
                    return(true);
                }
            }
            else
            {
                //We might have been blocked from attaching too closely to the zipline. Let's make sure that we can actually attach
                if (zipline.GetDistToClosestPointOnZipline(GetAttachPoint()) > m_ZiplineReachRadius)
                {
                    return(false);
                }
                Vector3 travelSpeed = zipline.GetTravelVelocity(GetAttachPoint(), m_ControlledCollider.GetVelocity());
                if (zipline.GetDistToEnd(GetAttachPoint(), travelSpeed) < zipline.GetLetGoDistance())
                {
                    return(false);
                }
                return(true);
            }
        }
        return(false);
    }
Example #5
0
 private void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.collider.CompareTag("Zipline"))
     {
         Zipline zipline = hit.transform.parent.gameObject.GetComponent <Zipline>();
         zipLineCarrier = hit.transform;
         zipline?.Move(zipLineSpeed, hit.point);
         isZipLining = true;
     }
 }
Example #6
0
    // Use this for initialization
    void Start()
    {
        Collider collider = GetComponent <Collider>();

        distToGround = collider.bounds.extents.y;
        doubleJump   = true;
        jumpCom      = false;
        rb           = GetComponent <Rigidbody>();
        zip          = this.gameObject.GetComponent <Zipline>();
    }
Example #7
0
    private void OnDisable()
    {
        StopAllCoroutines();

        slideFX.Stop();
        slideSFX.Stop();

        jumpLock         = false;
        zipline.Disabled = true;
        zipline          = null;
    }
Example #8
0
    //Called whenever this module is started (was inactive, now is active)
    protected override void StartModuleImpl()
    {
        Zipline zipline = FindZipline();

        if (zipline)
        {
            //Find our zipline, attach ourselves to it from the bottom or top depending on whether or not it is marked as a "skateline"
            m_CurrentZipline = zipline;
            m_IsSkating      = zipline.IsSkateLine();
            Vector3 newPoint = zipline.GetClosestPointOnZipline(GetAttachPoint());
            SetAttachPoint(newPoint);
        }
    }
Example #9
0
    private void SetZippingState(Zipline zipline)
    {
        zippingMovement.zipline = zipline;

        groundMovement.enabled   = false;
        airborneMovement.enabled = false;
        zippingMovement.enabled  = true;

        EndAttack();

        //cameraPriorityManager.SetFocus(CameraPriorityManager.GameState.PlatformAirborne);

        movementState = MovementState.Zipping;
    }
Example #10
0
    Zipline FindZipline()
    {
        Zipline best      = null;
        float   best_dist = m_ZiplineReachRadius;

        //Check for ziplines first (lines we hang from), so check around the top of our capsule
        Vector3 point = m_ControlledCollider.GetUpCenter();

        Collider[] results = Physics.OverlapSphere(point, m_ZiplineReachRadius * 2.0f, m_ZiplineMask, QueryTriggerInteraction.Collide);
        if (results.Length > 0)
        {
            for (int i = 0; i < results.Length; i++)
            {
                Zipline zipline = results[i].GetComponent <Zipline>();
                if (zipline != null && !zipline.IsSkateLine())
                {
                    float dist = zipline.GetDistToClosestPointOnZipline(point);
                    if (dist <= best_dist)
                    {
                        best_dist = dist;
                        best      = zipline;
                    }
                }
            }
        }
        //Now check for skatelines (lines we stand on top of), so check around the bottom of our capsule
        point   = m_ControlledCollider.GetDownCenter();
        results = Physics.OverlapSphere(point, m_ZiplineReachRadius * 2.0f, m_ZiplineMask, QueryTriggerInteraction.Collide);
        if (results.Length > 0)
        {
            for (int i = 0; i < results.Length; i++)
            {
                Zipline zipline = results[i].GetComponent <Zipline>();
                if (zipline != null && zipline.IsSkateLine())
                {
                    float dist = zipline.GetDistToClosestPointOnZipline(point);
                    if (dist <= best_dist)
                    {
                        best_dist = dist;
                        best      = zipline;
                    }
                }
            }
        }
        return(best);
    }
Example #11
0
        public static List <Zipline> ReadZplFile(string basePath, string mapNumber)
        {
            var allFiles = Directory.GetFiles(basePath, "*.zpl", SearchOption.AllDirectories);
            var fullPath = allFiles.Where(x => !x.Contains("expansion1.pak-out")).Single(x => x.EndsWith($"ugd{mapNumber}.zpl"));
            var data     = File.ReadAllLines(fullPath);

            var     ziplines = new List <Zipline>();
            Zipline current  = null;

            foreach (var entry in data)
            {
                var line = entry.Split(" ").Where(x => x != string.Empty).ToArray();
                if (line.Length == 0)
                {
                    continue;
                }
                if (line[0] == "zip_begin_path")
                {
                    current        = new Zipline();
                    current.PathId = ziplines.Count() + 1;
                }

                if (line[0] == "zip_is_teleporter" && line[1] == "true")
                {
                    current.IsTeleporter = true;
                }

                if (line[0] == "zip_path_point")
                {
                    current.PathPoints.Add(new System.Numerics.Vector3(float.Parse(line[1]), float.Parse(line[2]), float.Parse(line[3])));
                }

                if (line[0] == "zip_end_path")
                {
                    ziplines.Add(current);
                    current = null;
                }
            }

            return(ziplines);
        }
Example #12
0
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.collider.CompareTag("Pushable"))
        {
            Rigidbody rb      = hit.gameObject.GetComponent <Rigidbody>();
            Vector3   dir     = rb.transform.position - transform.position;
            Vector3   pushDir = new Vector3(dir.x, 0f, dir.x);
            rb.AddForce(pushDir * speed);
        }

        if (Input.GetKey(interact))
        {
            if (hit.collider.CompareTag("Rope"))
            {
                if (!isSwinging)
                {
                    Rigidbody rb      = hit.transform.parent.gameObject.GetComponent <Rigidbody>();
                    Vector3   dir     = rb.transform.position - transform.position;
                    float     fl      = Max(dir.x, dir.z);
                    Vector3   pushDir = new Vector3(dir.x / Abs(fl), 0f, dir.z / Abs(fl));
                    rb.AddForce(pushDir * ropeSpeed);
                    rope      = rb.transform;
                    hitOffset = hit.point - rope.position;
                    rope.GetChild(0).GetComponent <CapsuleCollider>().enabled = false;
                    isSwinging = true;
                }
            }
            if (hit.collider.CompareTag("Zipline"))
            {
                Zipline zipline = hit.transform.parent.gameObject.GetComponent <Zipline>();
                zipLineCarrier = hit.transform;
                zipline?.Move(zipLineSpeed, hit.point);
                isZipLining = true;
            }
        }
    }
    public void findLocation()
    {
        //curProj.GetComponent<Projectile>().firedBy = this;

        if (hooked)
        {
            //loc = hit.point;
            //isFlying = true;
            //fpcRigidBody.velocity = Vector3.zero;
            //FPC.canMove = false;
            //lineRenderer.enabled = true;
            //doCast = false;
            RaycastHit hit;
            if (curProj != null)
            {
                lineRenderer.SetPosition(1, curProj.transform.position);
                if (Physics.Raycast(curProj.transform.position, curProj.transform.forward, out hit))
                {
                    loc = hit.point;
                }
            }
        }

        else
        {
            if (curProj == null)
            {
                return;
            }

            if (Physics.Raycast(cam.transform.position, curProj.transform.position - cam.transform.position, out hit))
            {
                advancedMovement am = hit.collider.GetComponent <advancedMovement>();

                if (hit.collider.tag == "Player" || hit.collider.tag == "Player 2")
                {
                    if (am.collided == true && !hit.collider.GetComponent <Death>().IsDead&& !am.isGrounded())
                    {
                        hit.collider.GetComponent <Death>().Kill();
                        return;
                    }

                    Zipline    otherPlayerZip = hit.collider.gameObject.GetComponent <Zipline>();
                    RaycastHit hit2;
                    if (Physics.Raycast(otherPlayerZip.cam.transform.position, curProj.transform.forward, out hit2))
                    {
                        otherPlayerZip.curProj  = curProj;
                        otherPlayerZip.loc      = hit2.point;
                        otherPlayerZip.isFlying = true;
                        otherPlayerZip.fpcRigidBody.velocity = Vector3.zero;
                        otherPlayerZip.FPC.canMove           = false;
                        otherPlayerZip.lineRenderer.SetPosition(1, curProj.transform.position);
                        otherPlayerZip.lineRenderer.enabled = true;
                        otherPlayerZip.hooked = true;
                        //otherPlayerZip.spawnProj(otherPlayerZip.transform.position, curProj.transform.rotation);
                        otherPlayerZip.doCast = true;
                        doCast = false;
                    }
                }

                else if (hit.collider.tag != "Projectile")
                {
                    loc      = hit.point;
                    isFlying = true;
                    fpcRigidBody.velocity = Vector3.zero;
                    FPC.canMove           = false;
                    lineRenderer.enabled  = true;
                    lineRenderer.SetPosition(1, hit.point);
                    doCast = false;
                }
            }
        }
    }
Example #14
0
 //Called whenever this module is ended (was active, now is inactive)
 protected override void EndModuleImpl()
 {
     m_LastZiplineClimbTime = Time.time;
     m_CurrentZipline       = null;
 }
Example #15
0
    //Performs interaction with gameObject based on its tag
    //Executed when player is near interactables and presses "E"
    void Interact(GameObject interactable)
    {
        if (interactable != null)
        {
            //If interactable is a torch, check that we have enough light to activate it and that it is not already lit
            //If all conditions are met, light the torch, reduce lightAmt by cost
            if (interactable.CompareTag("Torch"))
            {
                TorchScript tScript = interactable.GetComponent <TorchScript>();
                if (tScript != null)
                {
                    if (lightAmt > torchCost && !tScript.lit)
                    {
                        tScript.LightTorch();
                        lightAmt -= torchCost;
                    }
                }
            }

            else if (interactable.CompareTag("Campfire"))
            {
                CampfireScript cScript = interactable.GetComponent <CampfireScript>();
                if (cScript != null)
                {
                    if (lightAmt > torchCost && cScript.isLit == false)
                    {
                        cScript.LightCampfire();
                        lightAmt -= torchCost;
                    }
                    else if (lightAmt > torchCost && cScript.isLit == true)
                    {
                        lightAmt             = (lightAmt + cScript.campLightAmt) / 2;
                        cScript.campLightAmt = (lightAmt + cScript.campLightAmt) / 2;
                    }
                }
            }

            //If interactable is a source, give player light from the source and destroy it
            else if (interactable.CompareTag("Source"))
            {
                SourceScript sScript = interactable.GetComponent <SourceScript>();
                if (sScript != null)
                {
                    lightAmt += sScript.lightStored;
                    Destroy(interactable);
                }
            }


            else if (interactable.CompareTag("Bomb"))
            {
                Bomb bomb = interactable.GetComponent <Bomb>();
                if (bomb != null)
                {
                    bomb.Ignite();
                }
            }

            else if (interactable.CompareTag("Zipline"))
            {
                Zipline zScript = interactable.GetComponentInParent <Zipline>();
                if (zScript != null)
                {
                    if (lightAmt > ziplineCost && !zScript.isActive)
                    {
                        zScript.Activate();
                        lightAmt -= ziplineCost;
                    }
                    else
                    {
                        if (zScript.isActive)
                        {
                            Vector3 startAnchor = interactable.transform.position;
                            Vector3 endAnchor;
                            if (interactable.transform == zScript.AnchorA)
                            {
                                endAnchor = zScript.AnchorB.position;
                            }
                            else
                            {
                                endAnchor = zScript.AnchorA.position;
                            }
                            StartCoroutine(UseZipline(startAnchor, endAnchor));
                        }
                    }
                }
            }
        }
    }
Example #16
0
    void Start()
    {
        //anim.Play("TestAnim");
        // anim["TestAnim"].speed = 0;
        // anim["TestAnim"].wrapMode = WrapMode.Loop;



        for (int i = 0; i < actorAnimation.Length; i++)
        {
            actorAnimation[i].Play("Walk");
            actorAnimation[i]["Walk"].speed     = 0;
            actorAnimation[i]["Walk"].wrapMode  = WrapMode.Loop;
            actorAnimation[i]["Walk"].blendMode = AnimationBlendMode.Blend;

            actorAnimation[i].Play("Jump");
            actorAnimation[i]["Jump"].speed     = 0;
            actorAnimation[i]["Jump"].wrapMode  = WrapMode.Loop;
            actorAnimation[i]["Jump"].blendMode = AnimationBlendMode.Blend;

            actorAnimation[i].Play("Idle");
            actorAnimation[i]["Idle"].speed     = 0;
            actorAnimation[i]["Idle"].wrapMode  = WrapMode.Loop;
            actorAnimation[i]["Idle"].blendMode = AnimationBlendMode.Blend;

            actorAnimation[i].Play("Falling");
            actorAnimation[i]["Falling"].speed     = 0;
            actorAnimation[i]["Falling"].wrapMode  = WrapMode.Loop;
            actorAnimation[i]["Falling"].blendMode = AnimationBlendMode.Blend;

            actorAnimation[i].Play("Death");
            actorAnimation[i]["Death"].speed = 0;
            //actorAnimation[i]["Death"].wrapMode = WrapMode.Loop;
            actorAnimation[i]["Death"].blendMode = AnimationBlendMode.Blend;
        }

        timeline = new Timeline();

        timeline.layerMask = ~LayerMask.GetMask("Platform");



        //
        Actor[] actor = new Actor[agent.Length];
        for (int i = 0; i < actor.Length; i++)
        {
            actor[i] = new Actor(agent[i].transform.position);
        }
        //
        MovableObject[] movableObject = new MovableObject[movableObjects.Length];
        for (int i = 0; i < movableObject.Length; i++)
        {
            RaycastHit hit;
            Physics.Raycast(movableObjects[i].transform.position, Vector3.down, out hit);
            movableObject[i] = new MovableObject(movableObjects[i].transform.position, hit.point, 10, 0, 0);
        }
        //
        DartWall[] dartWalls = new DartWall[dartwallObjects.Length];
        for (int i = 0; i < dartWalls.Length; i++)
        {
            dartWalls[i] = new DartWall(dartwallObjects[i].transform.position, dartwallObjects[i].transform.localScale, dartwallObjects[i].transform.rotation, new PressurePlate(dartwallObjects[i].transform.GetChild(0).transform.position, dartwallObjects[i].transform.GetChild(0).transform.localScale));
        }
        //
        Zipline[] ziplines = new Zipline[ziplineObjects.Length];
        for (int i = 0; i < ziplines.Length; i++)
        {
            Vector3[] point = new Vector3[2];
            point[0]    = ziplineObjects[i].transform.position;
            point[1]    = ziplineObjects[i].transform.GetChild(0).transform.position;
            ziplines[i] = new Zipline(point);
        }
        //
        SpikeTrap[] spikeTrap = new SpikeTrap[spikeObjects.Length];
        for (int i = 0; i < spikeTrap.Length; i++)
        {
            if (spikeObjects[i] != null)
            {
                Vector3[] STpoint = new Vector3[2];
                STpoint[0]   = spikeObjects[i].transform.GetChild(1).transform.position;
                STpoint[1]   = STpoint[0] + new Vector3(0, 2.75f, 0);
                spikeTrap[i] = new SpikeTrap(STpoint, STpoint[0], spikeObjects[i].transform.localScale, new PressurePlate(spikeObjects[i].transform.GetChild(0).transform.position, spikeObjects[i].transform.GetChild(0).transform.localScale));
            }
        }
        //
        UnstableFloor[] unstableFloors = new UnstableFloor[unstableFloorObjects.Length];
        for (int i = 0; i < unstableFloors.Length; i++)
        {
            Vector3[] UFpoint = new Vector3[2];
            UFpoint[0]        = unstableFloorObjects[i].transform.position;
            UFpoint[1]        = UFpoint[0] + Vector3.down * 25;
            unstableFloors[i] = new UnstableFloor(UFpoint[0], unstableFloorObjects[i].transform.localScale, UFpoint);
        }
        //
        MovingPlatformSet[] movingPlatformSet = new MovingPlatformSet[movingPlatformSetObjects.Length];
        for (int i = 0; i < movingPlatformSet.Length; i++)
        {
            int platforms          = 0;
            int pressurePlateChild = 0;
            int a = 0;
            foreach (Transform child in movingPlatformSetObjects[i].transform)
            {
                if (child.transform.tag == "Platform")
                {
                    platforms++;
                }
                else
                {
                    pressurePlateChild = a;
                }
                a++;
            }

            MovingPlatform[] movingPlatforms = new MovingPlatform[platforms];
            for (int j = 0; j < platforms; j++)
            {
                Vector3[] point = new Vector3[2];
                point[0]           = movingPlatformSetObjects[i].transform.GetChild(j).transform.position;
                point[1]           = point[0] + movingPlatformSetObjects[i].transform.GetChild(j).transform.forward * 4;
                movingPlatforms[j] = new MovingPlatform(point[0], movingPlatformSetObjects[i].transform.GetChild(j).transform.localScale, point);
            }

            movingPlatformSet[i] = new MovingPlatformSet(movingPlatforms, new PressurePlate(movingPlatformSetObjects[i].transform.GetChild(pressurePlateChild).transform.position, movingPlatformSetObjects[i].transform.GetChild(pressurePlateChild).transform.localScale));

            //movingPlatformSet[i].movingPlatforms = new MovingPlatform[movingPlatformSetObjects[i].transform.childCount];
        }
        //
        EndArea[] endAreas = new EndArea[endAreaObjects.Length];
        for (int i = 0; i < endAreas.Length; i++)
        {
            endAreas[i] = new EndArea(endAreaObjects[i].transform.position, endAreaObjects[i].transform.localScale);
        }

        timeline.Init(timelineSlider.maxValue, actor, movableObject, dartWalls, ziplines, spikeTrap, unstableFloors, movingPlatformSet, endAreas);
        //Timeline.RotateTowardsObject(timeline, timeline.turret[0], timeline.actor[0], 3);
        UpdateTimelineParts();

        SetTimelineCurrentValue(0);
    }