//TODO: Stop displaying ghost tower IFF it's not destroyed already (via tower placement) void OnNodeMouseExit(object caller, TowerPlaceSelectEventArgs args) { if (flag_placement_in_progress) { RemoveGhost(); } }
void OnNodeSelect(object caller, TowerPlaceSelectEventArgs args) { //Debug.Log("node selected"); //TODO: Have an actual, nonmagical cost //handle placing tower //Can only place if there is no tower already present and we are currently trying to place a tower if (flag_placement_in_progress) { if (!args.node.IsOccupied()) { //Debug.Log("placement attempt"); if (Resource_Inventory.TryTakeResources(tower_to_place.price_list)) { RemoveGhostFade(); Tower_V2 tower_instance = Instantiate(tower_to_place, new Vector3(0, 0, 0), Quaternion.identity); //if the node can't attach the new tower instance, we destroy it if (!args.node.TryAttachTower(tower_instance)) { //Debug.Log("placement attempt failed! destroying instance..."); Destroy(tower_instance); } else { //Debug.Log("placement attempt successful!"); EndTowerPlacement(); } TowerPlacedEvent?.Invoke(this, new TowerV2RefEventArgs(tower_instance)); } else { //Write tower construction failed! code here. //Text bubble explains why placement cant happen. Make sure this isnt spammable!? Text_Bubble.CreateTemporaryTextBubble("Not enough resources!", info_bubble_duration, args.node.gameObject.transform.position); } } else { //TODO: Tower failed! reason: space is already occupied! Text_Bubble.CreateTemporaryTextBubble("Space occuupied!", info_bubble_duration, args.node.gameObject.transform.position); } } }
//TODO: //[DONE?] Display ghost tower on mouse enter IFF flag_placement_in_progress //[DONE?] Provide contextual hint (blue / red) showing if tower is legally placeable at the Node //Need: Node Occupied status, current resource amount. //TODO: Must continue to update current resource amount and check to see if we need to change from red to blue // Can change to a continuecheckforresources coroutine or something that ends at the other stop conds in this listener impl void OnNodeMouseEnter(object caller, TowerPlaceSelectEventArgs args) { //Decision tree of ghost rendering, Might be better to handle differently but this works for now if (flag_placement_in_progress) { if (args.node.IsOccupied()) { RenderGhostRed(args.position.position); //oops... we're going to have to live with this transform "position" mislabel for now... } else { if (Resource_Inventory.CheckResourcesAvailable(tower_to_place.price_list)) { RenderGhostBlue(args.position.position); } else { RenderGhostRed(args.position.position); } } } }
void OnNodeSelect(object caller, TowerPlaceSelectEventArgs args) { //Debug.Log("node selected"); //handle placing tower if (flag_placement_in_progress) { //Debug.Log("placement attempt"); Tower_V2 tower_instance = Instantiate(tower_to_place, new Vector3(0, 0, 0), Quaternion.identity); //if the node can't attach the new tower instance, we destroy it if (!args.node.TryAttachTower(tower_instance)) { //Debug.Log("placement attempt failed! destroying instance..."); Destroy(tower_instance); } else { //Debug.Log("placement attempt successful!"); flag_placement_in_progress = false; } } }