示例#1
0
        //Drawing
        internal static void Draw()
        {
            //Clear the graphics device
            Graphics.Device.Clear(Color.Transparent);

            //Check if there are any post processing effects
            if (postProcessing.Count > 0)
            {
                //Draw to a render target
                Device.SetRenderTarget(target);
                Device.Clear(Color.Transparent);
            }

            //Begin the spritebatches
            spriteBatches.Begin();

            //If the current game state is not null, draw it
            if (X.CurrentState != null)
            {
                X.CurrentState.Draw(spriteBatches);
            }

            //Draw the other components
            GameConsole.Draw(spriteBatches);
            AchievementHolder.Draw(spriteBatches);

            //End the spritebatches
            spriteBatches.End();

            if (postProcessing.Count > 0)
            {
                Device.SetRenderTarget(null);
                Texture2D texture = target;

                //Apply all effects
                for (int i = 0; i < postProcessing.Count; i++)
                {
                    texture = postProcessing[i].Apply(texture, effectBatch, Vector2.Zero);
                }

                //Draw to the screen
                Device.SetRenderTarget(null);
                effectBatch.Begin();
                effectBatch.Draw(texture, Vector2.Zero, Color.White);
                effectBatch.End();
            }

            //Frame rate counter
            FrameRateCounter.Draw();
        }
示例#2
0
        //Update and draw
        protected override void Update(GameTime gameTime)
        {
            //Save the game time
            Time.Update(gameTime);

            //Update X
            X.Update(gameTime);

            //Update all components
            InputManager.Update();
            GameConsole.Update();
            AchievementHolder.Update();
            FrameRateCounter.Update();
            Timer.UpdateAll();
            Stopwatch.UpdateAll();

            base.Update(gameTime);
        }
 void OnGUI()
 {
     holder = FindObjectOfType <AchievementHolder>();
     if (holder == null)
     {
         holder = new GameObject("AchievementHolder").AddComponent <AchievementHolder>();
         holder.listOfAchievements = new List <AchievementComponent>();
         //CreateBlankAchievement();
     }
     Undo.RecordObject(holder, "Achievement Holder");
     scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
     EditorGUILayout.BeginVertical();
     EditorGUILayout.LabelField("Achievements", EditorStyles.boldLabel);
     for (int i = 0; i < holder.listOfAchievements.Count; i++)
     {
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.BeginVertical();
         holder[i].key    = EditorGUILayout.TextField("Key", holder[i].key);
         holder[i].myName = EditorGUILayout.TextField("Name", holder[i].myName);
         EditorGUILayout.LabelField("Description");
         holder[i].description   = EditorGUILayout.TextArea(holder[i].description);           //EditorGUILayout.TextField("Description", holder[i].description);
         holder[i].isIncremental = EditorGUILayout.Toggle("Incremental", holder[i].isIncremental);
         if (holder[i].isIncremental)
         {
             holder[i].goal = EditorGUILayout.IntField("Goal", holder[i].goal);
         }
         EditorGUILayout.EndVertical();
         holder[i].lockedTexture   = (Texture)EditorGUILayout.ObjectField("Locked Texture", holder[i].lockedTexture, typeof(Texture), true);
         holder[i].unlockedTexture = (Texture)EditorGUILayout.ObjectField("Unlocked Texture", holder[i].unlockedTexture, typeof(Texture), true);
         EditorGUILayout.EndHorizontal();
         if (GUILayout.Button("Remove Achievement", GUILayout.MaxWidth(200f)))
         {
             GameObject o = holder[i].gameObject;
             holder[i].KillMe();
             holder.listOfAchievements.Remove(holder[i]);
             holder.listOfAchievements.TrimExcess();
             DestroyImmediate(o);
         }
         EditorGUILayout.Space();
         if (holder[i] == null)
         {
             return;
         }
         if (holder[i].nameTextMesh)
         {
             holder[i].nameTextMesh.text = holder[i].myName;
         }
         if (holder[i].descriptionTextMesh)
         {
             holder[i].descriptionTextMesh.text = holder[i].description;
         }
         if (holder[i].icon)
         {
             holder[i].icon.GetComponent <Renderer>().sharedMaterial             = new Material(holder[i].icon.GetComponent <Renderer>().sharedMaterial);
             holder[i].icon.GetComponent <Renderer>().sharedMaterial.mainTexture = holder[i].lockedTexture;
         }
         if (holder[i].progress)
         {
             if (!holder[i].isIncremental)
             {
                 holder[i].progress.GetComponent <Renderer>().enabled = false;
             }
         }
         holder[i].CommitChanges();
     }
     EditorGUILayout.EndVertical();
     EditorGUILayout.BeginVertical();
     EditorGUILayout.BeginHorizontal();
     generateContainer = EditorGUILayout.Toggle("Generate Container", generateContainer);
     if (generateContainer)
     {
         container = (GameObject)EditorGUILayout.ObjectField("Container", container, typeof(GameObject), true);
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.BeginHorizontal();
     if (GUILayout.Button("New Achievement"))
     {
         CreateBlankAchievement();
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.EndVertical();
     EditorGUILayout.EndScrollView();
 }
示例#4
0
    void OnGUI()
    {
        holder = FindObjectOfType<AchievementHolder>();
        if(holder == null)
        {
            holder = new GameObject("AchievementHolder").AddComponent<AchievementHolder>();
            holder.listOfAchievements = new List<AchievementComponent>();
            //CreateBlankAchievement();
        }
        Undo.RecordObject (holder,"Achievement Holder");
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField ("Achievements", EditorStyles.boldLabel);
        for(int i = 0; i<holder.listOfAchievements.Count; i++)
        {

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            holder[i].key = EditorGUILayout.TextField ("Key",holder[i].key);
            holder[i].myName = EditorGUILayout.TextField ("Name", holder[i].myName);
            EditorGUILayout.LabelField("Description");
            holder[i].description = EditorGUILayout.TextArea (holder[i].description);//EditorGUILayout.TextField("Description", holder[i].description);
            holder[i].isIncremental = EditorGUILayout.Toggle ("Incremental", holder[i].isIncremental);
            if(holder[i].isIncremental)
            {
                holder[i].goal = EditorGUILayout.IntField("Goal", holder[i].goal);
            }
            EditorGUILayout.EndVertical ();
            holder[i].lockedTexture = (Texture)EditorGUILayout.ObjectField("Locked Texture",holder[i].lockedTexture,typeof(Texture),true);
            holder[i].unlockedTexture = (Texture)EditorGUILayout.ObjectField("Unlocked Texture",holder[i].unlockedTexture,typeof(Texture),true);
            EditorGUILayout.EndHorizontal();
            if(GUILayout.Button ("Remove Achievement", GUILayout.MaxWidth (200f)))
            {
                GameObject o = holder[i].gameObject;
                holder[i].KillMe() ;
                holder.listOfAchievements.Remove (holder[i]);
                holder.listOfAchievements.TrimExcess();
                DestroyImmediate(o);
            }
            EditorGUILayout.Space ();
            if(holder[i] == null)
            {
                return;
            }
            if(holder[i].nameTextMesh)
            {
                holder[i].nameTextMesh.text = holder[i].myName;
            }
            if(holder[i].descriptionTextMesh)
            {
                holder[i].descriptionTextMesh.text = holder[i].description;
            }
            if(holder[i].icon)
            {
                holder[i].icon.GetComponent<Renderer>().sharedMaterial = new Material(holder[i].icon.GetComponent<Renderer>().sharedMaterial);
                holder[i].icon.GetComponent<Renderer>().sharedMaterial.mainTexture = holder[i].lockedTexture;
            }
            if(holder[i].progress)
            {
                if(!holder[i].isIncremental)
                {
                    holder[i].progress.GetComponent<Renderer>().enabled = false;
                }
            }
            holder[i].CommitChanges();

        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        generateContainer = EditorGUILayout.Toggle ("Generate Container",generateContainer);
        if(generateContainer)
        {
            container = (GameObject)EditorGUILayout.ObjectField("Container",container,typeof(GameObject),true);
        }
        EditorGUILayout.EndHorizontal ();
        EditorGUILayout.BeginHorizontal();
        if(GUILayout.Button ("New Achievement"))
        {
            CreateBlankAchievement();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }