/******************************************** PRIMITIVES ********************************************** * This section holds all our primitives, which are the functions that the FSM will be allowed to use.* * In principle, any unit's main loop should only call primitives. * ******************************************************************************************************/ /// <summary> /// Place une unité dans la zone d'apparition en faisant attention au collisions /// </summary> /// <param name="type">type de l'unité</param> public bool SpawnUnit(BotType type) { if (!this.CanCreate(type)) { return(false); } GameObject unit = Instantiate(type.PrefabByType(), this.transform.position + this.transform.forward * 2.0f, this.transform.rotation * Quaternion.Euler(0.0f, Random.Range(-20.0f, 20.0f), 0.0f), this.GetComponent <WarBotController>().TeamManager.GetComponent <TeamManager>().transform); this.GetComponent <WarBotController>().TeamManager.GetComponent <TeamManager>().InitUnit(unit, type); this.GetComponent <InventoryController>().Remove((int)type.UnitCost()); this.last_spawn = Time.time; return(true); }
/// <summary> /// Place une unité aux coordonnées indiquées /// </summary> /// <param name="type">type de l'unité</param> /// <param name="position">position de l'unité</param> /// <param name="orientation">orientation de l'unité</param> public void SpawnUnit(BotType type, Vector3 position, Quaternion orientation) { GameObject unit = Instantiate(type.PrefabByType(), position, orientation, this.transform); InitUnit(unit, type); }