void ShootBall(Vector3 dir) { GameManager.Inst.tmCameraTopView.gameObject.SetActive(false); startPoint.gameObject.SetActive(false); this.dir = dir; this.state = E_STATE.BallMoving; }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; if (player != null) { state = E_STATE.FOLLOW; } position = transform.position; }
public void SetState(E_STATE _state) { if (_state == E_STATE.KILLED && state != E_STATE.KILLED) { OnDeath(); } state = _state; //SHOULDN'T BE HERE BUT THERE IS NO EVENT SYSTEM SO IT'S HERE..... SRY FUTURE SMARTER ME :) SlothAnimationController.refrence.SetAnimation(_state); }
void GameStart() { m_eState = E_STATE.E_PLAY; m_seal.SetSteerActive(true); m_objBlocks.SetActive(true); m_seal.Flap(); m_textStateLabel.gameObject.SetActive(false); m_textStateLabel.text = ""; }
void Ready() { m_eState = E_STATE.E_READY; m_seal.SetSteerActive(false); m_objBlocks.SetActive(false); m_textScoreLabel.text = "Score : " + 0; m_textStateLabel.gameObject.SetActive(true); m_textStateLabel.text = "Ready"; }
public void SetCharacterState(E_STATE _State, bool _IsCharging, bool _Network = true) { if (PhotonNetwork.InRoom && _Network) { if (m_PhotonView.IsMine) { m_PhotonView.RPC("SetCharacterState_RPC", RpcTarget.All, (int)_State, _IsCharging); } } else { SetCharacterState_RPC((int)_State, _IsCharging); } }
private void SendOutgoingPackets(int dt) { this._accumulatedMillisec += dt; while (this._accumulatedMillisec > this.Config.MillisecPerSubTurn) { this._accumulatedMillisec -= this.Config.MillisecPerSubTurn; // ## Subturn. this._accumulatedSubTurn += 1; if (this._accumulatedSubTurn >= this.Config.SubTurnsPerTurn) { // ## Stepping Turn. { int steppedTurn = this._currentTurn + this.Config.TurnGap; List <IInputCommand> commands = this.Input.FlushCommands(); TurnData.TurnData turnData = new TurnData.TurnData(this.uuid, commands); NetworkPacket packet = new NetworkPacket(NetworkPacket.E_TYPE.TURN, steppedTurn, this.uuid, turnData); this.Network.Send(packet); } if (this._currentTurn < 0) { this._accumulatedSubTurn = 0; this._currentTurn += 1; } else { if (TryAdvanceTurn()) { this._accumulatedSubTurn = 0; this._currentTurn += 1; } else { this.State = E_STATE.DELAYED; } } break; } } }
IEnumerator OnBallMovingState(E_STATE eState) { Debug.Log("PlayManager:OnBallMovingState()"); // 공 이동 시작 for (int i = 0; i < listBall.Count; ++i) { listBall[i].dir = dir; listBall[i].state = Ball.E_STATE.Moving; yield return(new WaitForSeconds(BALL_SHOOTING_PERIOD)); } bool showMsg = false; float elpasedBall = 0f; while (fsm.IsEqualState(eState)) { elpasedBall += Time.deltaTime; lastCollisionTime += Time.deltaTime; if (elpasedBall > ConfigManager.Inst.maxBallElpasedTime) { if (!showMsg) { FastForward(); // UIManager.Inst.PopupMessage (Localization.Get("move_faster"), 1f); showMsg = true; } } if (lastCollisionTime > ConfigManager.Inst.maxNoCollBlock) { lastCollisionTime = 0f; UIManager.Inst.PopupMessage(Localization.Get("roll_ball"), 1f); RollBall(); } if (true == IsEndOfBallMoving()) { break; } yield return(null); } NormalForawrd(); state = E_STATE.BlockMoving; }
void GameOver() { ScrollObject[] arrayScrollObject = { }; m_eState = E_STATE.E_GAMEOVER; arrayScrollObject = GameObject.FindObjectsOfType <ScrollObject>(); foreach (ScrollObject so in arrayScrollObject) { so.enabled = false; } m_textStateLabel.gameObject.SetActive(true); m_textStateLabel.text = "GameOver"; }
IEnumerator OnIdleState(E_STATE eState) { // 준비 dir = Vector3.zero; MakeStartPoint(); while (fsm.IsEqualState(eState)) { yield return(null); } rootBall = null; // 가지고 있는 공 수 만큼 생성 for (int n = listBall.Count; n < ballCount; n++) { listBall.Add(Ball.Create(listBall[0].tm.localPosition, OnReachedBall)); } }
private bool TryAdvanceTurn() { int nextTurn = this._currentTurn + 1; Dictionary <string, TurnData.TurnData> userTurnDatas = this.TurnDataMgr[nextTurn]; if (userTurnDatas.Count != this.Config.PlayerCount) { return(false); } if (this.State == E_STATE.DELAYED) { this.State = E_STATE.PLAYING; // TODO(pyoung): is need delay for waiting slow peer? } this.Simulation.TurnSimulate(nextTurn, userTurnDatas); return(true); }
public void Init(bool isNew = true) { Release(); if (isNew) { score = 0; step = 1; ballCount = 1; } GameManager.Inst.goFloor.SetActive(true); MakeWallCollider(); MakeWall(); MakeFloorBlock(); MakeBall(); MakeStartPoint(); state = E_STATE.BlockMoving; }
IEnumerator OnGameOverState(E_STATE eState) { // DropOutBlock (); Debug.Log("PlayManger:OnGameOverState"); // UIManager.Inst.popupResult.gameObject.SetActive (true); if (null != cbGameResult) { cbGameResult(); fsm.Reset(); } yield return(null); /* * while(fsm.IsEqualState(eState)) * { * Debug.Log ("PlayManger:OnGameOverState"); * yield return null; * } */ }
public void Start(INetworkClient networkClient) { this.State = E_STATE.PLAYING; this.Network.Start(networkClient); }
public void SetCharacterState_RPC(int _State, bool _IsCharging) { m_State = (E_STATE)_State; m_IsCharging = _IsCharging; }
void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { ballCount++; return; } if (Input.GetKeyDown(KeyCode.Alpha2)) { ballCount--; return; } if (Input.GetKey(KeyCode.Alpha3)) { if (state == E_STATE.Idle) { state = E_STATE.BlockMoving; } return; } if (Input.GetKeyDown(KeyCode.Alpha4)) { ShiftBlock(); return; } if (Input.GetKeyDown(KeyCode.Alpha5)) { BreakRandomBlock(); return; } if (Input.GetKeyDown(KeyCode.Alpha9)) { StartCoroutine(ApplyDamageAllBlock(1)); return; } if (Input.GetKeyDown(KeyCode.Alpha8)) { StartCoroutine(ApplyDamageAllBlock(1000)); return; } if (Input.GetKeyDown(KeyCode.Alpha0)) { StartCoroutine(ApplyDamageOnlyBlock(1000)); return; } if (Input.GetKeyDown(KeyCode.Alpha6)) { state = E_STATE.GameOver; return; } if (Input.GetKeyDown(KeyCode.Alpha7)) { UIManager.Inst.PopupMessage("VERT!", 0.5f); VerticalRollBall(); return; } }
public void SetState(E_STATE state) { SetState(stateDictionary[state]); }
public void SetState(E_STATE newState) { state = newState; }
public virtual bool CheckStateChange(E_STATE check) => canChangeStateList.Contains(check);
// Update is called once per frame void Update() { switch (state) { case E_STATE.NORMAL: //Disable fire effect here? break; case E_STATE.IGNITED: //Mabye display some fire effect here? health.DamageHealth(fireDamageOverTime * Time.deltaTime); fireTime -= Time.deltaTime; //Enemy is no longer on fire if (fireTime <= 0.0f) { state = E_STATE.NORMAL; } break; } //Delayed death, use the dead() method for anything needing to happen on kill if (!alive) { deadTimer -= Time.deltaTime; if (deadTimer <= 0.0f) { spawner.Despawn(gameObject); } renderer.material.SetFloat("Dissolve_Value", (deadTimer * -1.0f) + 1.0f); acceleration = Vector3.zero; velocity = Vector3.zero; return; } //Sound groanTimer -= Time.deltaTime; if (groanTimer <= 0.0f) { //Randomize the pitch audio.pitch = originalPitch + (Random.Range(-1.0f, 1.0f) * pitchVariance); //Play a sound at random if (Random.value >= 0.5f) { audio.PlayOneShot(groan1); } else { audio.PlayOneShot(groan2); } //Countdown till next groan groanTimer = groanDelay + (Random.Range(-1.0f, 1.0f) * groanVariance); } //If we have no path get one if (path == -1) { attackLocked = false; if (p1HP.playerState == PlayerHealth.PlayerState.ALIVE) { path = 0; } else if (p2HP.playerState == PlayerHealth.PlayerState.ALIVE) { path = 1; } else { return; } } //Debug.Log(path); //Just incase if (path == 0 && p1HP.playerState != PlayerHealth.PlayerState.ALIVE) { path = -1; engaging = false; } else if (path == 1 && p2HP.playerState != PlayerHealth.PlayerState.ALIVE) { path = -1; engaging = false; } //Cycle through all behaviours or attack if (engaging) //Attack { if (target == null) { engaging = false; attackTimer = 0.0f; attackRecov = 0.0f; return; } //Move directly towards our target acceleration = target.transform.position - transform.position; attackTimer -= Time.deltaTime; if (attackLocked) { anim.SetBool("IsAttacking", true); if (attackTimer <= 0.0f && attackRecov <= 0.0f) { Attack(); //Allow movement and rotation again attackLocked = false; //Set the time for cooldown between attacks attackRecov = attackRate; } } else { attackRecov -= Time.deltaTime; } } else //Behaviours { anim.SetBool("IsAttacking", false); //Deadlock prevention! attackLocked = false; acceleration = Vector3.zero; foreach (BaseBehaviour b in behaviours) { acceleration += b.Update() * b.weight; } } //No up velocity acceleration.y = 0.0f; //Normalize it and multiply it by our speed acceleration.Normalize(); acceleration *= movementSpeed; //Prevent movement while attacking ------ if (attackLocked) { acceleration = Vector3.zero; velocity = Vector3.zero; } velocity += acceleration / mass; velocity *= drag; //rotate towards where we are going if (velocity != Vector3.zero) { anim.SetBool("IsMoving", true); transform.localRotation = Quaternion.LookRotation(velocity); //transform.rotation.SetFromToRotation(Vector3.zero, velocity); action = E_ACTION.MOVE; } else { anim.SetBool("IsMoving", false); } //Cap max velocity if (velocity.magnitude > movementSpeed) { velocity = Vector3.Normalize(velocity) * movementSpeed; } //Anchor the enemy to the floor (rigidbody raycast fix) transform.position = new Vector3(transform.position.x, 0.0f, transform.position.z); }
//Ignite this enemy public void Ignite(float _fire_strength = 10.0f, float _fire_duration = 5.0f) { state = E_STATE.IGNITED; fireDamageOverTime = _fire_strength; fireTime = _fire_duration; }
public void Stop() { this.State = E_STATE.SUSPENDED; this.Network.Stop(); }
protected override void Update() { base.Update(); float deltatime = Time.deltaTime; if (m_AttackDelayTimer > 0.0f) { m_AttackDelayTimer -= deltatime; if (m_AttackDelayTimer <= 0.0f) { m_AttackDelayTimer = 0.0f; } } if (m_FreezeTimer > 0.0f) { m_FreezeTimer -= deltatime; if (m_FreezeTimer <= 0.0f) { m_FreezeTimer = 0.0f; } } if (m_AttackLevelConnetTimer > 0.0f) { m_AttackLevelConnetTimer -= deltatime; if (m_AttackLevelConnetTimer <= 0.0f) { m_AttackLevelConnetTimer = 0.0f; m_AttackAniNumber = 0; } } if (PhotonNetwork.InRoom && !m_PhotonView.IsMine) { return; } if (m_IsAutoPlay) { if (m_AttackTarget != null) { if (m_AttackTarget.m_Character == null || m_AttackTarget.m_Character.m_Live == E_LIVE.DEAD) { m_AttackTarget = null; m_NavMeshController.ClearPath(); } } if (m_DicHateTarget.Count > 0) { foreach (HateTarget h in m_DicHateTarget.Values) { h.m_Hate -= deltatime * (1.0f + h.m_Hate * 0.1f); } } if (m_DicHateTarget.Count > 0) { List <int> deletekeys = new List <int>(); foreach (HateTarget h in m_DicHateTarget.Values) { if (h.m_Hate <= 0.0f || h.m_Character == null || h.m_Character.m_Live == E_LIVE.DEAD) { deletekeys.Add(h.m_Key); continue; } if (m_AttackTarget == null) { m_AttackTarget = h; break; } else if (h.m_Hate > m_AttackTarget.m_Hate) { m_AttackTarget = h; } } if (deletekeys.Count > 0) { for (int i = 0; i < deletekeys.Count; ++i) { m_DicHateTarget.Remove(deletekeys[i]); } } } } if (m_Live == E_LIVE.DEAD) { return; } if (m_IsCharging) { return; } if (m_FreezeTimer > 0.0f) { return; } if (m_IsAutoPlay) { bool useskill = false; if (m_ListActiveSkill.Count > 0) { for (int i = 0; i < m_ListActiveSkill.Count; ++i) { if (m_ListActiveSkill[i].AutoPlayLogic()) { useskill = true; break; } } } if (useskill) { return; } m_AutoPlayLogic?.Invoke(); } if (m_State != E_STATE.IDLE) { if (m_AttackDelayTimer <= 0.0f && !m_NavMeshController.IsUpdate()) { m_State = E_STATE.IDLE; SetStateAndAnimationNetwork(E_ANIMATION.IDLE, 0.25f, 1.0f, 0.0f); } } m_NavMeshController.UpdateTransform(transform, m_MovePerSpeed, m_RotatePerSpeed); }