private void LoadPlayer() { if (initialiationState != InitialiationState.Authenticated) { Debug.LogWarning("Trying to load player when not authenticated."); return; } initialiationState = InitialiationState.Loading; Debug.Log("Loading buildings"); gameSparksManager.GetPlayerBuildings((LogEventResponse response) => { if (response.HasErrors) { // handle bla } else { foreach (GSData buildingGSData in response.ScriptData.GetGSDataList("player_buildings")) { // GSData buildingGSData = buildingWrapperGSData.GetGSData("building"); Building buildingData = (Building)GSDataHelpers.GSDataToObject(buildingGSData); gameData.AddBuilding(buildingData); BuildingBehavior newBuilding = Instantiate <BuildingBehavior>(farmPrefab); newBuilding.SetPlaced(true); newBuilding.transform.position = new Vector2(buildingData.position.x, buildingData.position.y); dataGameObjectsMap.Add(buildingData, newBuilding.gameObject); } } }); Debug.Log("Loading player"); }
public void RemoveQueueElementFromSelected(MouseEvent mouseEvent) { int index = int.Parse(mouseEvent.srcElement.id); BuildingBehavior buildingBehavior = cameraController.selectedObjects[0].GetComponent <BuildingBehavior>(); buildingBehavior.DeleteFromProductionQuery(index); }
// Start is called before the first frame update void Start() { Button[] buttons = FindObjectsOfType <Button>(); foreach (Button button in buttons) { button.onClick.AddListener(HandleButton1Click); } this.buildingBehavior = building.GetComponent <BuildingBehavior>(); }
void Start() { starterColor = gameObject.GetComponent <Renderer>().material.color; buildingBehaviorRef = gameObject.GetComponent <BuildingBehavior>(); Menu = GameObject.Instantiate <GameObject>(Menu); Menu.SetActive(false); //foreach (var binding in ButtonBindings) //{ // binding.Button.onClick.AddListener(binding.ClickAction); //} }
public void BuyBuilderHut() { BuildingIdentity buildingIdentity = UIManager.Instance.UIWindowBuyBuilding.BuilerNo >= 0 ? LogicController.Instance.BuyBuilderHut(UIManager.Instance.UIWindowBuyBuilding.BuilerNo, this.BuildingBehavior.FirstZoneIndex) : LogicController.Instance.BuyBuilderHut(this.BuildingBehavior.FirstZoneIndex); this.BuildingLogicData = LogicController.Instance.GetBuildingObject(buildingIdentity); this.BuildingBehavior.BuildingLogicData = this.BuildingLogicData; BuildingBehavior bb = this.ConstructBuilding(); bb.transform.position = PositionConvertor.GetWorldPositionByBuildingTileIndex(this.BuildingBehavior.BuildingLogicData.BuildingPosition); SceneManager.Instance.CreateUpgradeFX(bb); }
void RebuildWall(BuildingBehavior buildingBehavior, bool enableBuild) { if (enableBuild) { buildingBehavior.Build(); } else if (buildingBehavior.BuildingLogicData.BuildingPosition != null) { buildingBehavior.FirstZoneIndex = buildingBehavior.BuildingLogicData.BuildingPosition; buildingBehavior.Build(); } }
public void UpdateUI() { UnityEngine.Profiling.Profiler.BeginSample("p UpdateUI"); // Profiler UI.document.Run("ClearInfo"); bool userObjects = false; if (cameraController.selectedObjects.Count > 0) { unitBaseBehaviorComponent = cameraController.selectedObjects[0].GetComponent <BaseBehavior>(); userObjects = unitBaseBehaviorComponent.team == cameraController.team && unitBaseBehaviorComponent.ownerId == cameraController.userId; } DisplayObjectsInfo(cameraController.selectedObjects); if (userObjects) { DisplayCommands(cameraController.selectedObjects); bool displaySkills = true; BuildingBehavior unitBuildingBehavior = cameraController.selectedObjects[0].GetComponent <BuildingBehavior>(); if (unitBuildingBehavior != null && unitBuildingBehavior.GetState() != BuildingBehavior.BuildingState.Builded) { displaySkills = false; } if (displaySkills) { DisplaySkillsInfo(cameraController.selectedObjects); } } if (cameraController.selectedObjects.Count == 1) { DisplayDetailInfo(cameraController.selectedObjects[0]); if (userObjects) { UpdateQueue(cameraController.selectedObjects[0]); } } else if (userObjects) { UpdateQueue(); } UnityEngine.Profiling.Profiler.EndSample(); // Profiler }
// Use this for initialization void Start() { projectorComponent = projector.GetComponent <Projector>(); projectorComponent.material = new Material(projectorComponent.material); baseBehaviorComponent = gameObject.GetComponent <BaseBehavior>(); cameraController = Camera.main.GetComponent <CameraController>(); buildingBehavior = gameObject.GetComponent <BuildingBehavior>(); canBeSelected = baseBehaviorComponent.canBeSelected; SetOutline(false); if (buildingBehavior != null && buildingBehavior.DisableUpdate()) { enabled = false; } SetSelect(false); }
public void PlaceBuilding() { Debug.Log("place buliding"); if (placingBuildingBehavior != null) { Debug.Log("canceling previous"); CancelPlacement(); } placingBuildingBehavior = Instantiate <BuildingBehavior>(farmPrefab); if (placingBuildingBehavior.gameObject != null) { Debug.Log("got a building to place"); } else { Debug.Log("it's broken, yo"); } }
private void ConfirmPlacement() { placingBuildingBehavior.SetPendingPlacement(true); gameSparksManager.BuyBuilding("farm", placingBuildingBehavior.transform.position, (LogEventResponse response) => { placingBuildingBehavior.SetPendingPlacement(false); if (!response.HasErrors) { placingBuildingBehavior.ConfirmPlacement(); placingBuildingBehavior = null; // Building buildingData = (Building)GSDataHelpers.GSDataToObject(buildingGSData); // gameData.AddBuilding(buildingData); // BuildingBehavior newBuilding = Instantiate<BuildingBehavior>(farmPrefab); // newBuilding.transform.position = new Vector2(buildingData.posX, buildingData.posY); // dataGameObjectsMap.Add(buildingData, newBuilding.gameObject); } }); }
public override void OnClick() { print("WallBehavior OnClick"); if (!UIManager.Instance.SceneFocus || !base.Created || !base.EnableCreate || base.MouseOrTouchDictionary.Count > 1) { if (SceneManager.Instance.SelectedAllWallList.Count == 0) { base.FirstZoneIndexPrevious = base.FirstZoneIndex; } //for (int i = 0; i < SceneManager.Instance.SelectedAllWallList.Count; i++) //{ // print("for================"); // BuildingBehavior buildingBehavior = SceneManager.Instance.SelectedAllWallList[i]; // buildingBehavior.FirstZoneIndexPrevious = buildingBehavior.FirstZoneIndex; //} return; } bool clickAllWallState = true; if (SceneManager.Instance.SelectedAllWallList.Contains(this)) { print("SceneManager.Instance.SelectedAllWallList.Contains"); for (int i = 0; i < SceneManager.Instance.SelectedAllWallList.Count; i++) { BuildingBehavior buildingBehavior = SceneManager.Instance.SelectedAllWallList[i]; buildingBehavior.FirstZoneIndexPrevious = buildingBehavior.FirstZoneIndex; } //base.FirstZoneIndexPrevious = base.FirstZoneIndex; clickAllWallState = this.OnClickAllWall(); if (!clickAllWallState) { return; } else { UIManager.Instance.HidePopuBtnByCurrentSelect(true); } } else { clickAllWallState = false; } if (base.FirstZoneIndex.Equals(base.FirstZoneIndexPrevious) && (base.PressPosition - CameraManager.Instance.MainCamera.transform.position).magnitude < 16 && this.m_AllowClick || clickAllWallState) { if (!base.CheckBuildingCreateStack()) { return; } base.IsClick = !base.IsClick; base.SetArrowState(base.IsClick); base.OnActiveBuildingFX(base.IsClick); } else { if (!base.IsClick) { print("WallBehavior CameraManager.Instance.OnClick();"); CameraManager.Instance.OnClick(); } if (SceneManager.Instance.SelectedAllWallList.Count == 0) { base.FirstZoneIndexPrevious = base.FirstZoneIndex; } } if (!base.CheckBuildingCreateStack()) { return; } if (base.IsClick && base.IsBuild) { AudioController.Play("BuildingPick"); } if (base.EnableCreate && !base.IsBuild) { base.Build(); } //this.BuildingBehavior.SetCellVisible(!this.BuildingBehavior.IsBuild); if (base.IsClick) { if (SceneManager.Instance.PickableObjectCurrentSelect != null && SceneManager.Instance.PickableObjectCurrentSelect != this) { SceneManager.Instance.PickableObjectCurrentSelect.OnUnSelect(false); } SceneManager.Instance.PickableObjectCurrentSelect = this; if (base.IsBuild) { UIManager.Instance.ShowPopupBtnByCurrentSelect(); } } else { if (SceneManager.Instance.PickableObjectCurrentSelect == this) { UIManager.Instance.HidePopuBtnByCurrentSelect(false); } } this.AjustBoxColliderSize(base.IsClick); }
private void CancelPlacement() { Destroy(placingBuildingBehavior.gameObject); placingBuildingBehavior = null; }
// Use this for initialization void Start() { parentBuilding = gameObject.transform.parent.GetComponent <BuildingBehavior>(); }
private void ConfirmPlacement() { placingBuildingBehavior.ConfirmPlacement(); placingBuildingBehavior = null; }
// Use this for initialization void Start() { parentBuilding = gameObject.transform.parent.GetComponent <BuildingBehavior>(); skylight = FindObjectsOfType <Terrain>()[0].GetComponent <SkyLight>(); }