예제 #1
0
    private bool DealDamage(Transform target)
    {
        float damage = amplified ? AMP_DAMAGE : BASE_DAMAGE;

        UFTrigger trig = target.GetComponent <UFTrigger>();

        if (trig != null && trig.triggeredByWeapon)
        {
            trig.ExternalTrigger();
            return(true);
        }

        UFDestructible dstr = target.GetComponent <UFDestructible>();

        if (dstr != null)
        {
            dstr.DealDamage(damage);
            return(true);
        }

        UFClutter clut = target.GetComponentInParent <UFClutter>();

        if (clut != null && clut.life > 0f)
        {
            clut.Damage(damage);
            return(true);
        }

        //no valid damage target
        return(false);
    }
예제 #2
0
    private void Trigger()
    {
        //sync this trigger press over the network if necessary
        if (permanent && !permanentTriggered)
        {
            permanentTriggered = true;
            UFLevel.SyncTrigger(ownID);
        }

        if (resetsRemaining > 0)
        {
            resetsRemaining--;
        }
        else if (resetsRemaining == 0)
        {
            return;
        }

        insideTime = -resetDelay;
        buttonTime = 0f;

        foreach (int link in links)
        {
            Activate(link);
        }

        if (switchRef >= 0)
        {
            IDRef     swtch = UFLevel.GetByID(switchRef);
            UFClutter s     = swtch.objectRef.GetComponent <UFClutter>();
            s.Activate(true);
        }
    }
예제 #3
0
    private void Die()
    {
        gameObject.SetActive(false);
        if (rubblePrefab != null)
        {
            Transform  parent = transform.parent;
            Vector3    pos    = transform.position;
            Quaternion rot    = transform.rotation;
            GameObject g      = Instantiate(rubblePrefab, pos, rot, parent);
            UFClutter  rubble = g.GetComponent <UFClutter>();
            if (rubble == null)
            {
                rubble = g.AddComponent <UFClutter>();
            }
            rubble.life = 0f;

            if (rubbleIsSolid)
            {
                rubble.EnsureColliders();
            }
            else
            {
                foreach (Collider c in rubble.GetComponentsInChildren <Collider>())
                {
                    c.enabled = false;
                }
                g.AddComponent <SelfDestruct>().time = 5f;
            }
        }
    }
예제 #4
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");
    }