forked from samOtero/PTDGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request samOtero#13 from samOtero/feat/create-tower-at-start
feat: create towers at start add isBattling
- Loading branch information
Showing
8 changed files
with
118 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PartyManager : MonoBehaviour | ||
{ | ||
public GameObject TowerTemplate; | ||
public UnitParty currentParty; | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
init(); | ||
} | ||
|
||
private void init() { | ||
Debug.Log("initializing party..."); | ||
|
||
// Loop through all the party spots and create a unit for each one | ||
for(var i=0; i < currentParty.party.Count; i++) { | ||
var container = currentParty.party[i]; | ||
if (container.unit) Destroy(container.unit); | ||
container.unit = CreateTower(container.profile, i); | ||
container.hasBeenCreated = true; | ||
} | ||
|
||
Debug.Log("party initialized"); | ||
} | ||
|
||
// Create unit from a profile | ||
private Unit CreateTower(UnitProfile profile, int partyPosition) { | ||
var unitTemplate = TowerTemplate; //Would get which template we need from the profile, for now we just have only one | ||
var newUnit = Instantiate(unitTemplate, transform); | ||
var unitGfxName = UnitProfile.GetUnitGfxName(profile.unitID); | ||
newUnit.name = "Tower_"+unitGfxName; | ||
|
||
// Get graphic resource | ||
var graphicResourceName = "unitGfx/"+unitGfxName; | ||
var unitGfx = Object.Instantiate(Resources.Load(graphicResourceName), newUnit.transform) as GameObject; | ||
unitGfx.name = "unitGfx"; | ||
|
||
//Set unit script | ||
var unitScript = newUnit.GetComponent<Unit>(); | ||
unitScript.doInit(profile); | ||
unitScript.partyPos = partyPosition; | ||
|
||
return unitScript; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters