Ejemplo n.º 1
0
    public void SwimState(UFLiquid liquid)
    {
        if (motionState == MotionState.climb || motionState == MotionState.noClip)
        {
            return;
        }

        this.liquid   = liquid;
        motionState   = MotionState.swim;
        this.platform = null;
    }
Ejemplo n.º 2
0
 public void SetLiquid(UFLiquid liquid)
 {
     this.liquid = liquid;
 }
Ejemplo n.º 3
0
    private string GetInfo(RaycastHit hit)
    {
        if (hit.collider == null)
        {
            return("Void");
        }
        Transform target = hit.collider.transform;

        if (target.GetComponent <Collider>().isTrigger)
        {
            UFForceRegion force = target.GetComponent <UFForceRegion>();
            if (force != null)
            {
                switch (force.type)
                {
                case UFForceRegion.ForceType.AddVel:
                    return("Push region");

                case UFForceRegion.ForceType.Climb:
                    switch (force.soundType)
                    {
                    case UFLevelStructure.ClimbingRegion.ClimbingType.Fence:
                        return("Climbable\nFence");

                    case UFLevelStructure.ClimbingRegion.ClimbingType.Ladder:
                        return("Ladder");

                    case UFLevelStructure.ClimbingRegion.ClimbingType.Undefined:
                        return("Climbable");
                    }
                    break;

                case UFForceRegion.ForceType.SetVel:
                    return("Jump pad");
                }
            }

            UFLiquid liquid = target.GetComponent <UFLiquid>();
            if (liquid != null)
            {
                switch (liquid.type)
                {
                case UFLevelStructure.Room.LiquidProperties.LiquidType.Acid:
                    return("Acid");

                case UFLevelStructure.Room.LiquidProperties.LiquidType.Lava:
                    return("Lava");

                case UFLevelStructure.Room.LiquidProperties.LiquidType.Water:
                    return("Water");

                case UFLevelStructure.Room.LiquidProperties.LiquidType.Undefined:
                    return("Unkown\nLiquid");
                }
            }

            UFTrigger trig = target.GetComponent <UFTrigger>();
            if (trig != null)
            {
                if (trig.requireUseKey)
                {
                    if (trig.resetsRemaining == 0)
                    {
                        return("Spent\nButton\nArea");
                    }
                    else
                    {
                        return("Button\nArea");
                    }
                }

                foreach (int link in trig.links)
                {
                    IDRef idRef = UFLevel.GetByID(link);
                    switch (idRef.type)
                    {
                    case IDRef.Type.Event:
                        UFEvent eventRef = idRef.objectRef.GetComponent <UFEvent>();

                        switch (eventRef.type)
                        {
                        case UFLevelStructure.Event.EventType.Continuous_Damage:
                            bool insta = eventRef.int1 <= 0 || eventRef.int1 >= 100;
                            if (insta)
                            {
                                return("Death\nTrigger");
                            }
                            else
                            {
                                return("Damage\nArea");
                            }

                        case UFLevelStructure.Event.EventType.Teleport_Player:
                        case UFLevelStructure.Event.EventType.Teleport:
                            return("Teleporter");
                        }
                        break;
                    }
                }

                return("Trigger");
            }

            /*
             * if(target.GetComponentInParent<UFPlayerInfo>())
             *  return "Level\nBounds";
             */

            if (target.GetComponentInParent <MapFinish>())
            {
                return("Finish\nTrigger");
            }
        }
        else
        {
            if (target.name.StartsWith("StaticVisible"))
            {
                return("Solid");
            }

            if (target.name.StartsWith("StaticIcy"))
            {
                return("Slippery");
            }

            if (target.name.StartsWith("StaticInvisible"))
            {
                if (hit.normal.y > .7f)
                {
                    return("Invisible\nFloor");
                }
                else if (hit.normal.y < -.7f)
                {
                    return("Invisible\nCeiling");
                }
                else
                {
                    return("Invisible\nWall");
                }
            }

            if (target.parent != null)
            {
                switch (target.parent.name)
                {
                case "Scrollers":
                    return("Scroller");

                case "PortalGeometry":
                    return("Illegal\nGeometry");

                case "Moving geometry":
                    return("Mover");
                }
            }

            UFClutter clutter = target.GetComponentInParent <UFClutter>();
            if (clutter != null)
            {
                if (clutter.isSwitch)
                {
                    return("Switch");
                }
                else if (clutter.life <= 0f)
                {
                    return("Solid\nClutter");
                }
                else
                {
                    return("Destru-\nctible\nClutter");
                }
            }

            UFDestructible destr = target.GetComponent <UFDestructible>();
            if (destr != null)
            {
                string life    = UFUtils.GetShortFormat(destr.currentLife, 4);
                string maxLife = UFUtils.GetShortFormat(destr.life, 4);
                return("Destru-\nctible\n" + life + "/" + maxLife);
            }

            if (target.name.ToLower().Contains("help"))
            {
                return("Secret\nFix");
            }
        }

        Debug.Log("Could not recognize target: " + target);
        return("Unkown");
    }
Ejemplo n.º 4
0
    private void MoveUpdate()
    {
        //input
        bool allow    = !IgnoreInput();
        bool right    = allow && InputInterface.input.GetKey("right");
        bool left     = allow && InputInterface.input.GetKey("left");
        bool forward  = allow && InputInterface.input.GetKey("forward");
        bool backward = allow && InputInterface.input.GetKey("backward");
        bool jumpDown = allow && InputInterface.input.GetKeyDown("jump");
        bool jump     = allow && InputInterface.input.GetKey("jump");
        bool crouch   = allow && InputInterface.input.GetKey("crouch");

        hitGround = false;

        //horizontal motion
        float   horizontal = (right ? 1f : 0f) - (left ? 1f : 0f);
        float   vertical   = (forward ? 1f : 0f) - (backward ? 1f : 0f);
        Vector3 movement   = (new Vector3(horizontal, 0f, vertical)).normalized;

        movement = transform.rotation * movement;

        //move with platform
        if (this.platform != null && cc.enabled)
        {
            Vector3 platformDelta = this.platform.position - this.lastPlatformPosition;
            cc.Move(platformDelta);
            if (this.platform != null)
            {
                this.lastPlatformPosition = this.platform.position;
            }
        }

        //liquid vision
        bool liqVision = false;

        if (liquid != null)
        {
            liqVision = playerCamera.transform.position.y < liquid.absoluteY;
            if (liqVision)
            {
                liquid.SetLiquidVision();
                GetComponent <UFPlayerWeapons>().SetLiquidVision(true, liquid.color);
                liquidNeedsReset = true;
            }
            liquid = null;
        }
        if (!liqVision && liquidNeedsReset)
        {
            liquidNeedsReset = false;
            UFLevel.playerInfo.ResetVision();
            GetComponent <UFPlayerWeapons>().SetLiquidVision(false, Color.clear);
        }

        //seperate motion updates
        switch (motionState)
        {
        case MotionState.ground:
            GroundMove(movement, jumpDown, crouch);
            break;

        case MotionState.air:
            AirMove(movement, jump, jumpDown);
            break;

        case MotionState.crouch:
            CrouchMove(movement, crouch);
            break;

        case MotionState.climb:
            ClimbMove(movement, jump, crouch);
            break;

        case MotionState.swim:
            SwimMove(movement, jump, crouch);
            break;

        case MotionState.noClip:
            NoClip(movement, jump, crouch);
            break;

        default:
            Debug.LogError("Unexpected motion state: " + motionState);
            break;
        }

        //animation motion state
        float angle = Vector3.SignedAngle(this.forward, horVel, Vector3.up);

        SetAnimation("Moving", horSpeed > 0.01f);
        SetAnimation("MoveAngle", false, angle);

        //crouching
        if (crouch && !crouching)
        {
            crouching = true;
        }
        else if (!crouch && crouching)
        {
            crouching = !CheckIfClearForStandingUp();
        }

        SetCharacterHeight(crouching);

        //others
        shiftVelocity = Vector3.zero;
    }