private void Execute(StateUI stateUI, bool isSave = true) { if (_currentWindow != null) { _currentWindow.Cancel(); } switch (stateUI) { case StateUI.None: Debug.Log("Panel None"); break; case StateUI.PanelOne: _currentWindow = _panelOne; break; case StateUI.PanelTwo: _currentWindow = _panelTwo; break; default: throw new System.ArgumentNullException("None Panel"); } _currentWindow.Execute(); if (isSave) { _stateUIs.Push(stateUI); } }
private void Execute(StateUI stateUI, bool isSave = true) { if (_currentWindow != null) { _currentWindow.Cancel(); } switch (stateUI) { case StateUI.PanelOne: _currentWindow = _panelOne; break; case StateUI.PanelTwo: _currentWindow = _panelTwo; break; default: break; } _currentWindow.Execute(); if (isSave) { _stateUi.Push(stateUI); } }
void Awake() { m_Button = GetComponent<Button> (); m_StateUIPanel = transform.GetComponentInParent<StateUI> (); if (m_Button != null) { m_Button.onClick.AddListener (OnButtonClick); } }
public void ChangeState(StateUI state) { currentState = state; StartCoroutine(state.ToString() + "State"); if (OnStateChanged != null) { OnStateChanged.Invoke(this, new EventArgs <int>((int)state)); } }
private void EndScreen() { Time.timeScale = 1.0f; menuState.SetActive(false); playState.transform.Find("Canvas").GetComponent <Canvas>().enabled = false; endState.SetActive(true); curStateUI = endState.GetComponent <StateUI>(); curStateUI.SetActive(); }
// Use this for initialization void Start() { UIObject = GameObject.Find("State UI"); UI = UIObject.GetComponent <StateUI>(); cameraObject = GameObject.Find("Main Camera"); mainCamera = cameraObject.GetComponent <MainCamera>(); speechRecObj = GameObject.Find("SpeechRecognition"); speech = speechRecObj.GetComponent <SpeechRecognition01>(); }
private void Menu() { menuState = GameObject.Find("MenuState"); playState = GameObject.Find("PlayState"); endState = GameObject.Find("EndState"); Time.timeScale = 1.0f; menuState.SetActive(true); //playState.SetActive(false); playState.transform.Find("Canvas").GetComponent <Canvas>().enabled = false; endState.SetActive(false); curStateUI = menuState.GetComponent <StateUI>(); curStateUI.SetActive(); }
private void StatusOnClick(GameObject obj) { //Debug.Log(obj.name); StateUI sui = obj.GetComponent <StateUI>(); if (sui.attacker == null || (!(sui.attacker is HeroAttacker) && sui.attacker.IsDead)) { return; } Camera.main.GetComponent <FollowTarget>().target = sui.attacker.transform; foreach (var item in statusUI) { item.ShowFocus(false); } sui.ShowFocus(true); tarState.SetAttakcer(sui.attacker.Target); }
public void RegStateUI(StateUI ui) { GameObject button = ui.gameObject; UIEventListener.Get(button).onClick = StatusOnClick; if (ui.name == "targetStatus") { tarState = ui; return; } if (ui.name == "heroStatus") { heroState = ui; return; } this.statusUI.Add(ui); this.statusUI.Sort((a, b) => b.transform.position.y.CompareTo(a.transform.position.y)); }
public void Execute(StateUI stateUI) { if (CurrentWindow != null) { CurrentWindow.Cancel(); } if (stateUI == StateUI.None) { if (StateUIStack.Count == 0) { return; } StateUIStack.Pop(); if (StateUIStack.Count == 0) { return; } stateUI = StateUIStack.Pop(); } StateUIStack.Push(stateUI); switch (stateUI) { case StateUI.HealthBarUISimple: CurrentWindow = _healthBarUISimple; CurrentWindow.GetPlayerData(_dataPlayer); break; case StateUI.HealthBarUIWhisSpacePlane: CurrentWindow = _healthBarUIWhisSpacePlane; CurrentWindow.GetPlayerData(_dataPlayer); break; default: break; } CurrentWindow.Execute(); }
} //yohan added public virtual void Init() { // Initialization if (gameObject.name == "Player") { //stats = SaveSystem.LoadStats(); //stats.maxHP = SaveSystem.LoadStats().maxHP; stats = new Stats(initHP, initAtt, initSpeed, initAttSpeed, initDefence, initCriticalChance); } else { stats = new Stats(initHP, initAtt, initSpeed, initAttSpeed, initDefence, initCriticalChance); } InitInput(); InitInventory(); movement = GetComponent <IMovement>(); combat = GetComponent <ICombat>(); movement.Init(this); combat.Init(this); gm = GameObject.FindWithTag("GameController").GetComponent <GameManager>(); damageTextPrefab = Resources.Load <GameObject>("Prefabs/DamageText"); dialogTextPrefab = Resources.Load <GameObject>("Prefabs/StateUIs/FloatingDialog"); GameObject stateUIInstance = Instantiate(stateUIPrefab, Vector3.zero, Quaternion.identity) as GameObject; stateUI = stateUIInstance.GetComponentInChildren <StateUI>(); InitStateUI(); animationManager = GetComponent <AnimationManager>(); if (animationManager != null) { animationManager.Init(); } IsAlive = true; ActivateAutoAim = true; drops = new Drops(creditDrop, energyDrop); gm.WorldColorChange += OnWorldColorChange; audioManager = FindObjectOfType <AudioManager>(); }
public override void Init() { base.Init(); var weaponSocket1 = transform.Find("Hand1"); var weaponSocket2 = transform.Find("Hand2"); dualWieldSockets = new Transform[] { weaponSocket1, weaponSocket2 }; singleSocket = new Transform[] { weaponSocket2 }; singleSocket2 = new Transform[] { weaponSocket1 }; weaponColl1 = weaponSocket1.GetComponent <BoxCollider2D>(); weaponColl2 = weaponSocket2.GetComponent <BoxCollider2D>(); Physics2D.IgnoreCollision (weaponColl2, GetComponent <BoxCollider2D>()); Physics2D.IgnoreCollision (weaponColl1, GetComponent <BoxCollider2D>()); InitNewInventory(); ActivateWeapon(inventory.Weapons[0]); // 2. check if save file exists -load if exists -make a new one if not--------------------------------------------------- /*if (File.Exists(Application.dataPath + "/savedata/HubData.test")) * { * hubSaveData = SaveSystem.Loadhubsavedata(); * inventory.SetCredits(hubSaveData.credits); * Debug.Log("HubDataLoaded" + hubSaveData.credits); * } * else * { * hubSaveData = new HubSaveData(10); * inventory.SetCredits(hubSaveData.credits); * } * if (File.Exists(Application.dataPath + "/savedata/autoSaveData.test")) * { * LoadAndSetPlayer(SaveSystem.LoadAutoSaveData()); * } * else { CreateAutoSaveData(); } // causing Curl error 56: Receiving data failed with unitytls error code 1048578 * */ //3. inventory UI init (assential??) commented out - not in use. //4. Direction indication directionIndication = transform.Find("DirectionIndication"); sprite = directionIndication.transform.Find("DirectionSprite"); directionIndicationSprite = sprite.GetComponent <SpriteRenderer>(); //dIColor = directionIndicationSprite.color; //5. State UI init( hp bar etc ) GameObject stateUIInstanceFixe = Instantiate(stateUIPrefabFixe,/*Vector3.Zero*/ new Vector3(0.0f, 3000.0f, 0.0f), Quaternion.identity) as GameObject; stateUIFixe = stateUIInstanceFixe.GetComponentInChildren <StateUI>(); stateUIFixe.Init(this, true, true);// character, hasEnergy, isFixed //GetInventory().AddCredits(10);//tmp stateUIFixe.UpdateCredits();//tmp //6.VFX init gainEnergyEffect = Resources.Load <GameObject>("Prefabs/Effects/DropEnergyEffect"); justOnceSmoke = new bool[2]; //7. etc gm = GameObject.Find("GameManager").GetComponent <GameManager>(); //8. initiated! (needed for cameraControl. ) initiated = true; stateUII = GameObject.Find("PlayerStateUI(Clone)"); stateUII.GetComponent <StateUI>().Refresh(); //bonus justOnceSmoke = new bool[2]; //9. initate player die effect deadEffectObj = transform.Find("DeadEffect").gameObject; deadEffectAnimObj = transform.Find("DeadEffectAnim").gameObject; playerDeadBody = GameObject.Find("Player").transform.Find("PlayerDeadBody").gameObject; playerMainBody = new GameObject[6]; playerMainBody[0] = GameObject.Find("Player").transform.Find("Body").gameObject; playerMainBody[1] = GameObject.Find("Player").transform.Find("Face").gameObject; playerMainBody[2] = GameObject.Find("Player").transform.Find("Hand1").gameObject; playerMainBody[3] = GameObject.Find("Player").transform.Find("Hand2").gameObject; playerMainBody[4] = GameObject.Find("Player").transform.Find("Foot1").gameObject; playerMainBody[5] = GameObject.Find("Player").transform.Find("Foot2").gameObject; //load and set data playerComb = GetComponent <PlayerCombatV1>(); playerComb.weapons[0] = GetActiveWeapon(); //saveSystemManager.InitSaveData(); stateUIFixe.Refresh(); }