public void requestNewUnit(StateManager.EntityType unitType) { if (state.isServer) { RequestUnit req = new RequestUnit(); req.ownerID = networkID; req.unitType = unitType; HandleRequestUnit(req); } else { RequestUnit req = new RequestUnit(); req.ownerID = networkID; req.unitType = unitType; SendMessage(req); } }
public void HandleRequestUnit(RequestUnit ru) { Debug.Log("HANDLING REQUEST UNIT"); // Do logic to check if they can add a unit // if they cant, do nothing // if they can, make a unit and send an addUnit message out short netID = ru.ownerID; StateManager.EntityType unitType = ru.unitType; GameObject unit = state.AddUnit(netID, unitType, null); AddUnit addUnit = new AddUnit(); addUnit.ownerID = netID; addUnit.unit = new NetworkUnit(); addUnit.unit.id = unit.name; addUnit.unit.unitType = unitType; // send the new unit to connections SendMessage(addUnit); }
public Sprite UnitIcon(StateManager.EntityType type) { return(unitIcons[(int)type]); }
public void StartBuildUnit(StateManager.EntityType type) { unitIcon.gameObject.SetActive(true); unitIcon.sprite = UnitIcon(type); unitLoadingBar.fillAmount = 1; }