示例#1
0
 private void RenderLoadingZone(bool active)
 {
     this.curLoadingZone = FindObjectOfType <HumanAPI.LevelPassTrigger>();
     // get rid of previous loading zone visual
     if (this.loadingZoneVisual != null)
     {
         Destroy(this.loadingZoneVisual);
     }
     if (active && this.curLoadingZone)
     {
         this.loadingZoneVisual = this.generateHitboxVisual(this.curLoadingZone);
         this.loadingZoneVisual.SetActive(true);
     }
 }
示例#2
0
 private void RenderCheckpoints(bool active)
 {
     HumanAPI.Checkpoint[] lvlCPs = FindObjectsOfType <HumanAPI.Checkpoint>();
     // get rid of previous checkpoint visuals
     foreach (GameObject go in this.checkpointVisuals)
     {
         Destroy(go);
     }
     this.checkpointVisuals.Initialize();             // reset array
     //DebugMessage("Reset checkpointVisuals array");
     if (active)
     {
         HumanAPI.LevelPassTrigger theLoadZone = FindObjectOfType <HumanAPI.LevelPassTrigger>();
         for (int i = 0; i < lvlCPs.Length; i++)
         {
             if (lvlCPs[i].number != 0)                     // only generate visual if it's not the "first" checkpoint (where you spawn)
             {
                 this.checkpointVisuals[i] = this.generateHitboxVisual(lvlCPs[i]);
                 this.checkpointVisuals[i].GetComponent <Renderer>().material.SetColor("_Color", new Color(1.0f, 0.66f, 0.0f, 0.33f));                        // orange for checkpoints :)
                 this.checkpointVisuals[i].SetActive(true);
             }
         }
     }
 }
示例#3
0
        private void Start()
        {
            this.gameLevel = -1;

            this.curColor        = 0;
            this.curSpeedIter    = 0;
            this.maxSpeedReached = 0.0f;
            this.prevCpNum       = this.curCpNum = 0;

            this.renderCheckpoints = false;
            this.renderLoadingZone = false;
            this.renderSpeed       = false;
            this.renderMenu        = false;
            this.renderDebug       = false;

            this.debugText      = string.Empty;
            this.curLoadingZone = null;
            this.colorSwatch    = new Color[8] {
                Color.black, Color.white, Color.red, new Color(1.0f, 0.549f, 0.0f), new Color(1.0f, 1.0f, 0.0f), Color.green, Color.blue, new Color(0.5f, 0.0f, 0.5f)
            };                                                                                                                                                                                                     // black, white, and colors of rainbow

            this.theStyle = new GUIStyle()
            {
                wordWrap  = false,
                fontSize  = 48,
                alignment = TextAnchor.UpperCenter
            };
            this.theStyle.normal.textColor = this.colorSwatch[0];

            this.cubePrimitive    = GameObject.CreatePrimitive(PrimitiveType.Cube);
            this.capsulePrimitive = GameObject.CreatePrimitive(PrimitiveType.Capsule);
            this.spherePrimitive  = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            this.meshPrimitive    = GameObject.CreatePrimitive(PrimitiveType.Cube);          // dunno how to implement a mesh at the moment

            this.primitives    = new GameObject[4];
            this.primitives[0] = this.cubePrimitive;
            this.primitives[1] = this.capsulePrimitive;
            this.primitives[2] = this.spherePrimitive;
            this.primitives[3] = this.meshPrimitive;

            this.checkpointVisuals = new GameObject[50];

            this.loadingZoneVisual = null;

            foreach (GameObject theObject in this.primitives)
            {
                Renderer objRenderer = theObject.GetComponent <Renderer>();
                StandardShaderUtils.ChangeRenderMode(objRenderer.material, StandardShaderUtils.BlendMode.Transparent);
                objRenderer.material.SetColor("_Color", new Color(0.0f, 1.0f, 0.0f, 0.33f));                 // transparent green by default

                objRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;                 // so that it doesn't cast shadows on things
                objRenderer.receiveShadows    = false;

                theObject.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                theObject.GetComponent <Collider>().enabled = false;
                DontDestroyOnLoad(theObject);
                theObject.SetActive(false);
            }

            RenderCheckpoints(false);
            RenderLoadingZone(false);
            ResetAverage();
            RefreshMenuMessage();

            // print mod info to console
            int strLength;

            strLength = System.Math.Max(System.Math.Max(modAuthor.Length, modGame.Length), modName.Length);
            string equalSigns = string.Empty;

            for (int i = 0; i < modName.Length + 4; i++)
            {
                equalSigns += "=";
            }

            Shell.Print("<#FF8B00>" + equalSigns);
            Shell.Print(modName);
            Shell.Print("for " + modGame);
            Shell.Print("Written by: " + modAuthor);
            Shell.Print(equalSigns + "</color>");

            Shell.RegisterCommand("showcheckpoints", new System.Action <string>(this.SetRenderCheckpoints), "showcheckpoints\r\nToggle visual for checkpoints");
            Shell.RegisterCommand("showcps", new System.Action <string>(this.SetRenderCheckpoints), null);
            Shell.RegisterCommand("showcp", new System.Action <string>(this.SetRenderCheckpoints), null);
            Shell.RegisterCommand("showloadingzones", new System.Action <string>(this.SetRenderLoadingZone), "showloadingzones\r\nToggle visual for loading zones");
            Shell.RegisterCommand("showlzs", new System.Action <string>(this.SetRenderLoadingZone), null);
            Shell.RegisterCommand("showlz", new System.Action <string>(this.SetRenderLoadingZone), null);
            Shell.RegisterCommand("speedometer", new System.Action <string>(this.SetDisplaySpeedometer), "speedometer\r\nToggle speedometer");
            Shell.RegisterCommand("checkpointnum", new System.Action <string>(this.SetDisplayCheckpointNum), "checkpointnum\r\nToggle UI display of current & previous checkpoint");

            DebugMessage("Press \"NumPad-Enter\" to bring up the SpeedTools menu.\r\nAlternatively type \"help\" in console to see new console commands.\r\nNOTE: INVALIDATES SPEEDRUN IF USED; RESTART GAME WHEN DONE WITH PRACTICE", 16, false);
        }
示例#4
0
        private GameObject generateHitboxVisual(HumanAPI.LevelPassTrigger sourceObject)
        {
            /*
             * 0 = box/cube
             * 1 = capsule
             * 2 = sphere
             * 3 = mesh
             */
            int             colType = -1;
            GameObject      hitboxVisual;
            BoxCollider     boxCol     = sourceObject.gameObject.GetComponent <BoxCollider>();
            CapsuleCollider capsuleCol = sourceObject.gameObject.GetComponent <CapsuleCollider>();
            SphereCollider  sphereCol  = sourceObject.gameObject.GetComponent <SphereCollider>();
            MeshCollider    meshCol    = sourceObject.gameObject.GetComponent <MeshCollider>();

            //maybe add meshcollider as well

            if (boxCol)
            {
                colType = 0;
            }
            else if (capsuleCol)
            {
                colType = 1;
            }
            else if (sphereCol)
            {
                colType = 2;
            }
            else if (meshCol)
            {
                colType = 3;
            }

            switch (colType)
            {
            case 0:
                hitboxVisual = Instantiate(this.cubePrimitive);
                hitboxVisual.transform.localScale = new Vector3(boxCol.size.x * sourceObject.transform.localScale.x, boxCol.size.y * sourceObject.transform.localScale.y, boxCol.size.z * sourceObject.transform.localScale.z);
                hitboxVisual.transform.SetParent(sourceObject.transform, false);
                hitboxVisual.transform.position = boxCol.bounds.center;
                break;

            case 1:
                DebugMessage("Collider type is CapsuleCollider");
                hitboxVisual = Instantiate(this.capsulePrimitive);
                hitboxVisual.transform.localScale = new Vector3(capsuleCol.radius * 2 * capsuleCol.transform.localScale.x, capsuleCol.height * capsuleCol.transform.localScale.y, capsuleCol.radius * 2 * capsuleCol.transform.localScale.z);
                hitboxVisual.transform.SetParent(capsuleCol.transform, false);
                break;

            case 2:
                DebugMessage("Collider type is SphereCollider");
                hitboxVisual = Instantiate(this.spherePrimitive);
                hitboxVisual.transform.localScale = new Vector3(sphereCol.radius * 2 * sphereCol.transform.localScale.x, sphereCol.radius * 2 * sphereCol.transform.localScale.y, sphereCol.radius * 2 * sphereCol.transform.localScale.z);
                hitboxVisual.transform.SetParent(sphereCol.transform, false);
                break;

            default:
                DebugMessage("Collider type is MeshCollider or something else or nonexistant");
                hitboxVisual = Instantiate(this.cubePrimitive);
                hitboxVisual.transform.localScale = sourceObject.transform.localScale;
                hitboxVisual.transform.SetParent(sourceObject.transform, false);
                break;
            }

            hitboxVisual.name = "LoadingZoneVisual";
            return(hitboxVisual);
        }