UNITY | PROJECT | RPG Tutorial |8. Completing Quests

2
“QuestButton” Script
  • add GameObjects for indicating that we have taken the quest
  • set the GameObject off when the function, AcceptQuest() is activated
3-0
Adding Components to Script
3-1
Taking Quest
4
“QuestButton” Script
  • create a function, DeclineQuest()
  • make things not have happend
5-01.png
Setting Action for Button
5-1
Declining Quest
6
“GlobalEXP” Script
11
“GlobalEXP” Script
  • Be careful with the order of variables
    • we are going to show internalEXP variable, which is the path for currentEXP , static variable
    • so, put the static variable in the path variable

 

7
“GlobalEXP” GameObject
8
Creating Trigger
9
“QuestComplete” Script
  • Create Variables
  • in Update() method,
    • get the distance between the trigger and Player
  • in OnMouseOver() method,
    • when the distance is lower than a specific value,
      • turn on the UI
      • put the text in the UI
      • if Action button is pressed,
        • turn off the marker
        • add EXP by 100
        • turn off the UIs
        • turn off the Trigger
  • in OnMouseExit() method,
    • turn off the UIs
10-0
Adding Components in Script
10-1
Be Careful with the Component Structure
  • even though the marker is on from the first moment, with the fact that the marker belongs to a GameObject which is turned off, the marker is off automatically
  • move the maker outside of the object
12-0
QuestTrigger” Script
  • add variables for exMarker and Trigger
  • when retrieving the Sword from the chest, turn on the marker and trigger in the notice board
12-1
Declining Quest
12-2
Taking Quest
12-3
Retrieving Sword
12-4
Completing Quest

13

UNITY | PROJECT | RPG Tutorial |7.Triggers ,Weapons & Objectives

2
Making Clearing in Woods
3
Creating Collider as Trigger
4
“QuestTrigger” Script
  • create variables
    • the objective to configure
    • the flag to indicate we finish the objective
    • scale for the Objective
  • in Update() method,
    •  make if statement
      • change the locale scale of UI Text
      • make it disappear when the scale is 0
5
Adding Chest
5-1
Opening the top of Chest
6
Creating Animation for the top of Chest
7
Creating Animation with Transform.Rotation
8
Creating Animation with Transform,Rotation
8-1
Animtation Working
bandicam 2018-08-28 20-55-18-493
Adding “Animation” Component
9
Changing Setting in Dubug | Selecting “Legacy”
  • Since Animation Component is old one, to use it, we need to check Legacy option checked
12
Deselecting “Play Automatically”
12-1
10
Adding “Box Collider” as “Trigger”
13
Adding “Box Collider”
  • add Box Collider to prevent Player coming into Chest
14
Adding “Chest Trigger” Script to Trigger Collider
15
“ChestTrigger” Script
  • create Variable
    • for RayCasting to get the distance between Player and this Object itself
    • for Chest
    • for UIs
    • as a Flag to check whether we finish the obective
  • in Update() method,
    • get the distance
    • if the distance is lower than a specific value,
      • lower the scale of UI
      • make it disapear
  • in OnMouseDown() method,
    • when Cursor is on the object, and the distance is lower than a specific vlaue,
      • put the text into UI
      • make UIs appear
      • if Action button is pressed,
        • turn off the Box Collider
        • Play the animation of Chest
        • set the flag
        • turn off UIs
16
Adding Trigger & “Sword Trigger” Script
17
“Sword Trigger” script
  • create Variable
    • for RayCasting to get the distance between Player and this Object itself
    • for Sword
    • for UIs
    • as a Flag to check whether we finish the obective
  • in Update() method,
    • get the distance
    • if the distance is lower than a specific value,
      • lower the scale of UI
      • make it disapear
  • in OnMouseDown() method,
    • when Cursor is on the object, and the distance is lower than a specific vlaue,
      • put the text into UI
      • make UIs appear
      • if Action button is pressed,
        • turn off the Box Collider
        • Play the animation of Chest
        • set the flag
        • turn off UIs
17-1
Retriving Sword

 

UNITY | PROJECT | RPG Tutorial |5. RayCasting

2
Creating “PlayerCasting” script
3
“PlayerCasting” script
  • creating a static variable for the distance of RayCasting
    • create another variable as a internal path for the static variable
  • in Update() method,
    • imply a RayCasting from the mission board, with the direction of forward
    • with out keyword, put the information of RayCasting into hit variable
    • put the distance between the mission board and player in toTarget
    • connect the static variable and the path variable
3-1
RayCasting Working
4
Creating Text UI for indicating Key
5
Creating Text UI for indicating Action
6
InputManager | Adding a button
7
Adding a quest note with Plane
8
“Quest001” Script
  • creating Variables
  • in Update() method,
    • put the distance from the RayCasting in PlayerCasting Class  into “distance
      • for this, distanceFromTarget is set as Static
  • in OnMouseOver() method,
    • if the distance of RayCasting is less than 3,
      • set ActionButton and ActionText active
      • if Action button is pressed,
        • set actionButton, ActionText, and Player inactive
        • set UIQuest and Notice Camera active
  • in OnMouseExit() method,
    • set actionButton and actionText inactive
10
Adding RawImage UI | Making Notice UI for Quest
11
Setting Components off as default value
12
Notice Camera for the Quest
13
Making a Trigger with Cube
14
Making a Trigger with Cube
  • Be careful with the position of Triggers
  • If it’s buried in the other objects like the notice board, it is not detected by RayCasting
15
Put Components in the script
15-1
RayCasting Working
15-2
Action Working

UNITY | PROJECT | SPACE SHOOTER 2D | 11. Timer UI & GameTitle

2
Importing Timer UI

 

3
Adding Timer UI Image
  • Add an UI Image for Timer
    • Add Timer UI to “Source Image”
      • Press “Set Native Size”

 

4
Adding Timer Text
  • Add a UI Text for Timer Counter
    • Add Text for the default value
    • Change Font Style to “Bold”, Font Size to “30”
    • Add “Timer Controller” Script
    • Change Anchor to “Top-Right”

 

5
“TimerController” Script
  • Get the Reference for TimeUI
  • Claim “startTime”, “ellapsedTime” and “startCounter” as flag
  • Claim “minutes” and “seconds”
  • In “Start()” method
    • Set the flag to false
    • Get the Component of “Text”
  • Create a Function, “StartTimeCounter()” to start the Timer
    • Get the current time when the timer is started
    • Set the Flag to True
  • Create a Function, “StopTimeCounter()” to stop the Timer
    • Set the Flag to False
  • In “Update()” method,
    • if the flag is True (when it is on)
      • Get the Elapsed Time by subtracting “startTime” from the Current Time in this very frame
      • Get the minute and second based on the Elapsed Time
      • Update the Timer UI by accessing the Text Property with String.Format
6.1
“GameManager” Script
  • Add codes to Start and Stop the Timer
    • Get the Component of “TimerCounter” Class to use “StartTimeCounter()” and “StopTimeCounter()”
6.2
“Timer” Working

 

7.1
Importing “GameTitle”
  • Add “Game Title” image on the Hierarchy
    • Set the sorting layer to “Effect”

 

8
“GameManager” Script
  • Add Codes to Turn on & off Game Title by using “GameObject.SetActive()”
    • When Case “Opening”,
      • Set Game Title On
    • When Case “GamePlay”
      • Set Game Title Off
7.2
“GameTitle” Working

UNITY | PROJECT | SPACE SHOOTER 2D | 8. Lives UI, Play Button, & Game Manager

2
Importing UI Sprites
3
Adding UI Image
  • Adding UI Image for Score & Lives

 

4

  • Adding Sprite to UI Image as “Source Image”

 

5
UI Image Applied

 

6
UI Anchor

 

7.1
Adding & Configuring Sprite to UI Image for Scores UI
  • Adding Sprite to UI Image as “Source Image”

 

7.2
UI Anchor

 

8
Creating UI Text
  • Creating UI Text to count Player’s Life

 

9
Adding & Configuring UI Text to Image UI
  • In UI Text
    • set the default Text as “0”
    • change Font Style & Size
108-e1531887916889.png
UI Anchor

 

11
Creating UI Button
  • Create UI Button for Play Button

 

12

13

14
Adding Sprite to UI Button
  • In UI Button
    • Set the size
    • Add Sprites for “Target Graphic”(usual) & “Pressed Sprite”(pressed)

 

15
UI Anchor

 

16
Creating “GameManager” Script
17
Adding Reference
181.png
“GameManager” Script
  • To control PlayButton&Player with GameManager
    • create Public Object as a Reference
    • create an Enumeration, “GameManagerState” to tell Game State
      • Opening, GamePlay, and GameOver
    • create a Function, “UpdateGameManagerState()”
      • use “Switch Statement”
        • make 3 cases

 

19.1
“Play Button”
  • now, Play Button reacts to Clicking but nothing happens

 

19.2
“PlayerControl” Script
스크린샷 2018-07-18 오전 2.21.17
“Player”
20.1
“PlayerControl” Script
ec8aa4ed81aceba6b0ec83b7-2018-07-18-ec98a4eca084-1-22-31.png
“PlayerControl” Script
  • create “GameManager” GameObject as a reference
  • set “Player” inactive for the first moment of Game
  • In “Init()” method, which is called when Game Starts
    • set the current life(“lives”) as MaxLife
    • update UIText by using Text.text property
    • change the number(int “lives”) to string by using int.Tostring() method
    • set Player active when Game starts
  • In “OnTriggerEnter2D()” method(when a Collision with Player happens,)
    • the life is subtracted
    • when the life is 0,
      • use “SetManagerState” in “GameManager” Class with “GameOver”()*(putting the name of “enum”)
      • hide Player GameObject by set it “false”

 

8. Live UI, Play Button, - GameManager
“GameManager” Script
  • update “GameManager” Script
    • in “Start()” method
      • set “GMState” in “Opening”
    • in “UpdateGameManagerState()”
      • in case of “GamePlay”,
        • Set “PlayButton” active to hide it when Game Starts
        • Activate “Init()” method
    • Create” SetGameMangerState()” method to change the Game’s State, having “GameManagerState”(enum) as Parameter
    • in “StartGamePlay()” method
      • change “GMState” into “GamePlay”
      • Don’t forget to put “UpdateGameManagerState()”

 

 

21
“PlayButton” | Sprite & “On Click()”

 

  • In Play Button,
    • Add Sprite for “Target Graphics”(Usual) and “Pressed Sprite”(Pressed)
    • Add “On Click()” event and designate it “StartGamePlay()” method in “GameManager” Class
    • with this part, No Need to write to Star Game

 

231-e1531888420395.png
Adding Reference
ezgif.com-video-to-gif
“PlayButton” & “PlayerLife” working
26
“GameOver” Image added
  • Add “GameOver” Sprite
    • add the sprite to GameManager
    • add the Sprite to the scene
27
GameOver “Off”
  • Turn off “GameOver” for it to be hidden in the first moment of Game

 

28
“EnemySpawner” Script
  • Create a Function, “UnscheduleEnemySpawner()”, to stop the spawning when the game is over” by using “CancelInvoke()”

 

29
“GameManager” Script
  • Create “ChangeToOpeningState()” method
    • use “SetGameMangerState()” method
  • In Case of “GameOver”,
    • put “UnscheludeEnemySpawner()” method to stop the spanwing
  • In Case of “Opening”
    • turn off “GameOver” by using “GameObject.Setactive()”
30
Adding Reference
ezgif.com-video-to-gif
Game Working