// Use this for initialization void Start() { RectTransform background = GetComponent<RectTransform> (); backgroundWidth = background.sizeDelta.x; playerState = PlayerState.Instance; playerState.Health = 100; }
public override void ResetGenerationData() { base.ResetGenerationData(); currentState = PlayerState.RESPAWNING; currentCheckpoint = -1; }
public Zombie(Vector2 pos) { this.pos = pos; this.playerState = PlayerState.Jump; this.order = Order.Follow; animationPlayer.PlayAnimation(G.animations["zombie"]); }
PlayerState Move(PlayerState previous, KeyCode newKey) { float deltaX = 0, deltaY = 0, deltaZ = 0; float deltaRotationY = 0; switch (newKey) { case KeyCode.Q: deltaX = -0.5f; break; case KeyCode.S: deltaZ = -0.5f; break; case KeyCode.E: deltaX = 0.5f; break; case KeyCode.W: deltaZ = 0.5f; break; case KeyCode.A: deltaRotationY = -1f; break; case KeyCode.D: deltaRotationY = 1f; break; } return new PlayerState { posX = deltaX + previous.posX, posY = deltaY + previous.posY, posZ = deltaZ + previous.posZ, rotX = previous.rotX, rotY = deltaRotationY + previous.rotY, rotZ = previous.rotZ }; }
protected override void Awake() { base.Awake(); State = PlayerState.Normal; _audioSource = GetComponent<AudioSource>(); }
public void UpdateFromState(PlayerState state) { // first cache all of the upgrades unlocked levels //for(int i = 0; i < unlockedLevels.Length; i++) { // string upgradeName = unlockedLevels[i].name; // // int unlockedLevel; // if(state.upgradeUnlockTable.TryGetValue(upgradeName, out unlockedLevel)) { // unlockedLevels[i].level = unlockedLevel; // } //} string[] keys = state.upgradeUnlockTable.Keys.ToArray(); unlockedLevels = new UpgradePair[keys.Length]; for(int i = 0; i < keys.Length; i++) { unlockedLevels[i].name = keys[i]; int level = 0; state.upgradeUnlockTable.TryGetValue(keys[i], out level); unlockedLevels[i].level = level; } availablePoints = state.UpgradePoints; //then cache the equipped upgrades and their levels equippedUpgrades = new UpgradePair[state.equippedUpgrades.Count]; for(int i = 0; i < state.equippedUpgrades.Count; i++) { equippedUpgrades[i].level = state.equippedUpgrades[i].level; equippedUpgrades[i].name = state.equippedUpgrades[i].name; } }
private void StepForward() { // TODO: Parse dialogues/action tree using an XML File instead of a long case statement // case set A switch (pState) { case PlayerState.NORMAL: pState = PlayerState.INPUT; if (!inputPanel.activeSelf) inputPanel.SetActive(true); EventSystem.current.SetSelectedGameObject(inputField.gameObject, null); break; case PlayerState.NARRATIVE: StepNarrative(); break; case PlayerState.INPUT: pState = PlayerState.NORMAL; inputPanel.SetActive(false); break; case PlayerState.INTERACT: break; default: break; } // case set A end steps++; }
// Update is called once per frame void Update() { colTag = "Air"; switch (gameState) { case GameState.Playing: { if(playerState == PlayerState.Running) { Debug.Log(colTag); if (Input.GetKeyDown (KeyCode.Space)) { playerState = PlayerState.inAir; Jump(); anim.SetInteger("State", 1); } } if(playerState == PlayerState.inAir) { //Debug.Log(this.GetComponent<Rigidbody2D>().velocity.y); if(this.GetComponent<Rigidbody2D>().velocity.y == 0f ) { jumpNumber = 0; playerState = PlayerState.Running; anim.SetInteger("State", 0); } } break; } default: break; } }
//Cancel the currently displayed action public void CancelAction() { selectedUnit = null; m_tiles.ClearSelectedTiles(); m_hud.HideUnitInfo(); e_playerState = PlayerState.Default; }
public void ChangeMode(PlayerState playerState) { this.playerState = playerState; switch(this.playerState) { case PlayerState.Normal: this.parallaxMode = ParallaxMode.Normal; Debug.Log("----- Normal Mode -----"); break; // ------------------------------------------------------------------------------ case PlayerState.BoostMode: this.parallaxMode = ParallaxMode.Boost; AudioPlayer.Play(AudioPlayer.PLAYER_BOOST); gameVel = this.boostInfo.boostVel; break; // ------------------------------------------------------------------------------ case PlayerState.LaserMode: AudioPlayer.Play(AudioPlayer.PLAYER_LASER); break; // ------------------------------------------------------------------------------ case PlayerState.ScaryDogMode: AudioPlayer.Play(AudioPlayer.PLAYER_WOOF); break; // ------------------------------------------------------------------------------ case PlayerState.DyingMode: this.parallaxMode = ParallaxMode.Dying; break; } }
// Update is called once per frame void Update() { deathtimeout -= Time.deltaTime; animationtime -= Time.deltaTime; switch (state) { case PlayerState.ALIVE: //Things that you would call every frame while the character is alive if (myHealth.currentHealth <= 0) { state = PlayerState.DYING; } break; case PlayerState.DYING: //things you need to do to "kill" the character StartCoroutine (TriggerAnimator ("death")); animationtime = 4f; //animation.Play("MOB1_M1_Stand_Relaxed_Death_B"); //THIS IS THE THING THAT HELPS YOU //THE PLAYER IS NOW ONLY DYING FOR ONE FRAME AND The ANIMATION PLAY IS ONLY CALLED ONCE state = PlayerState.DEAD; break; case PlayerState.DEAD: //Anything you need to do to clean up the character such as removing them from the scene or respawning, etc. if(deathtimeout <= 0 && animationtime <= 0){ transform.position = GameObject.FindGameObjectWithTag ("Respawn").transform.position; myHealth.currentHealth = 100; deathtimeout = 4.0f; state = PlayerState.ALIVE; } break; } }
void KeyDownEvent() { if(Input.GetKeyDown(KeyCode.UpArrow)){ if(_state == PlayerState.standing) _state = PlayerState.running; newIndex = 1; if(newIndex != currentIndex) currentIndex = newIndex; currentDir = Vector2.up; } if(Input.GetKeyDown(KeyCode.DownArrow)){ if(_state == PlayerState.standing) _state = PlayerState.running; newIndex = 3; if(newIndex != currentIndex) currentIndex = newIndex; currentDir = -Vector2.up; } if(Input.GetKeyDown(KeyCode.LeftArrow)){ if(_state == PlayerState.standing) _state = PlayerState.running; newIndex = 2; if(newIndex != currentIndex) currentIndex = newIndex; currentDir = -Vector2.right; } if(Input.GetKeyDown(KeyCode.RightArrow)){ if(_state == PlayerState.standing) _state = PlayerState.running; newIndex = 0; if(newIndex != currentIndex) currentIndex = newIndex; currentDir = Vector2.right; } }
void Start () { player = GameObject.Find("Player"); playerState = player.GetComponent<PlayerState>(); ani = GetComponent<Animation>(); ani.Play("Idle"); }
public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState) { currentPlayer.actionsToExecuteAtBeginningOfNextTurn.Add( delegate() { currentPlayer.AddCoins(1); }); }
void Start () { // Assign spawners to spawners array spawners[0] = topAirSpawner; spawners[1] = midAirSpawner; spawners[2] = botAirSpawner; spawners[3] = groundSpawner; // Initialize texts to their respective GO's hudPlayerHealth = HudPlayerHealthObj.GetComponent<Text>(); hudPlayerGold = HudPlayerGoldObj.GetComponent<Text>(); hudPlayerXP = HudPlayerXPObj.GetComponent<Text>(); // Initialize wave-time to 0 timeSinceWave = 0; // Initialize PlayerState struct playerState = new PlayerState(startingPlayerHealth, xpMultiplier, startingPlayerGold, startingPlayerXP, firstToSecondLevelXP); // Initially disable attribute panel GameObject.Find("AttributePanel").SetActive(false); // Load attribute panel toggle label text ref attrPanelToggLabel = GameObject.Find("Label").GetComponent<Text>(); // Init ref to Canvas object canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); }
// Use this for initialization void Start() { _instance = this; isShowPanel = false; npcManager =NPCManager._instance; NPCDictionary = npcManager.GetNPCDctionary(); playerState = PlayerState._instance; mainControllerUI = UIController._instance; foreach (KeyValuePair<int, GameObject> item in NPCDictionary) { item.Value.GetComponent<NPCInfomation>().CommunicationStart += CommunicationTalk; } #region UI containItems = transform.Find("TalkContainer").Find("Scroll View").Find("Items").gameObject; talkLabel = containItems.transform.Find("TalkLabel").GetComponent<UILabel>(); shopButton = containItems.transform.Find("ShopButton").GetComponent<UIButton>(); questButton = containItems.transform.Find("QuestButton").GetComponent<UIButton>(); bagManagerUI = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("EquepMenu").GetComponent<UIBagManager>(); npcQuestManagerUI = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("NPCQuestPanel").GetComponent<UINPCQuestManager>(); #endregion gameObject.SetActive(false); }
public override void Update(GameTime gameTime) { if (!GameState.IsPaused) { if (GameState.IsEnd) { ShowLabels.ShowEndGame(); FirstSprite.HandleSpriteMovement(gameTime); SecondSprite.HandleSpriteMovement(gameTime); if (!GameState.IsEnd) { FirstSprite.Stop(); SecondSprite.Stop(); } } else { ShowLabels.ShowWinner(); ShowLabels.ShowRound(); firstState = FirstSprite.HandleSpriteMovement(gameTime); secondState = SecondSprite.HandleSpriteMovement(gameTime); if (firstState == PlayerState.Move || secondState == PlayerState.Move) CollideDetector.RepairMoveCollision(FirstSprite, SecondSprite, width); CollideDetector.HitCollision(FirstSprite, SecondSprite, gameTime); FirstHealthBar.Update(FirstSprite.Information.Health); SecondHealthBar.Update(SecondSprite.Information.Health); WinnerDetector.DetectWinner(gameTime, FirstSprite, SecondSprite); } base.Update(gameTime); } }
public static void StartNewGame() { Debug.Log("GameState StartNewGame"); CurrentRound = 0; Players = new List<PlayerState>(); for(var i=0; i<GameSettings.NumberOfPlayers; i++) { var pState = new PlayerState(i); switch(i) { case 0: default: pState.Color = new Color(.2f, .4f, 1); // blue break; case 1: pState.Color = Color.red; break; case 2: pState.Color = Color.green; break; case 3: pState.Color = new Color(1,0,1); // purple break; } Players.Add(pState); } AudioListener.volume = 1;// GameSettings.SoundVolume / 10f; IsGameStarted = true; }
public Player(Random rand) { pos = new Vector2(50, 1100); velocity = new Vector2(0, 0); acceleration = new Vector2(0, 0); forward = new Vector2(1, 0); pState = PlayerState.idle; dState = DirectionState.right; width = 23; height = 45; rect = new Rectangle((int)pos.X, (int)pos.Y, width, height); fps = 10.0; timePerFrame = 1.0 / fps; frame = 0; maxForce = 20f; maxSpeed = new Vector2(3f, 5f); decceleration = .9f; canJump = true; helmets = new Stack<Helmet>(); chestplates = new Stack<ChestPlate>(); gloves = new Stack<Gloves>(); this.rand = rand; chargeCounter = 0.0; armorScale = 1.0f; armorLevel = 0; invincible = false; Initialize(); }
public static void Is(Player player, int x, int y, int score, PlayerState state) { Assert.Equal(x, player.Pos.X); Assert.Equal(y, player.Pos.Y); Assert.Equal(score, player.Score); Assert.Equal(state, player.State); }
public void Input() { KeyboardState currentKeyBoardState = Keyboard.GetState(); if (currentKeyBoardState.IsKeyDown(Keys.Space)) { currentPlayerState = PlayerState.Flying; if (currentPlayerState == PlayerState.Flying) { Flying(); } if (currentPlayerState == PlayerState.Falling) { Falling(); } } if (currentKeyBoardState.IsKeyUp(Keys.Space)) { loopCount = 0; currentPlayerState = PlayerState.Falling; Falling(); } }
// Use this for initialization void Awake() { ItemInfoPanel = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("EquepMenu").Find("ItemInfoPanel").GetComponent<UIItemInfoPanel>(); playerState = PlayerState._instance; OnEquepChanged(); playerState.OnPlayerStateChanged += OnStateChanged; }
// Use this for initialization void Awake() { state = 3; playerHealth = GameObject.Find("Player").GetComponent<PlayerState>(); spikes = transform.Find("spiketrap_spikes"); a = GetComponent<AudioSource>(); }
void GameOver() { ePS = PlayerState.DEATH; SoundPlay(ESound.DEATH); GM.GameOver(); }
private void SetState(PlayerState new_state) { if (this.currentState != null) this.currentState.End (); this.currentState = new_state; this.currentState.Start (); }
void handleInput() { PlayerState state = playerState_.handleInput (); if (state != null) { playerState_ = state; } }
// public LevelState level; //Stats // public float timePlayed = 0.0F; public SafeState() { // current = new SafeState(); // allLevels = new List<LevelState>(); // level = new LevelState(); player = new PlayerState(); }
void FixedUpdate() { if (Input.GetAxisRaw("Switch Form") != 0 && m_StateTimer == 0) { m_Human.IsActive = !m_Human.IsActive; m_Spirit.IsActive = !m_Spirit.IsActive; if (m_Human.IsActive) { m_PlayerState = PlayerState.HUMAN; m_Camera.Following = m_Human.gameObject; } else { m_PlayerState = PlayerState.SPIRIT; m_Camera.Following = m_Spirit.gameObject; } m_Human.GetComponent<SpriteRenderer>().enabled = !m_Human.GetComponent<SpriteRenderer>().enabled; m_Spirit.GetComponent<SpriteRenderer>().enabled = !m_Spirit.GetComponent<SpriteRenderer>().enabled; ChangeSceneMode(); m_StateTimer = 0.5f; } else if (m_StateTimer > 0) { m_StateTimer -= Time.deltaTime; m_StateTimer = Mathf.Clamp(m_StateTimer, 0.0f, m_StateTimer); } }
// Use this for initialization protected override void Start() { base.Start(); pController = GetComponent<PlayerControllerIso>(); pState = PlayerState.RUNNING; canRoll = true; }
public PlayerBehavior() : base("PlayerBehavior") { this.direction = NONE; this.trans2D = null; this.currentState = PlayerState.Idle; }
public void AnotherFunction <T>(PlayerState <T> state)
void CheckPushPull() { // if player currently already pushing/pull an object then cancel the push/pull interaction if (currentState == PlayerState.PushingPulling) { CancelPushingPulling(); } // else check for any objects within distance to push/pull else { // Determine direction to cast ray Vector3 dir; if (facingDirection == FacingDirection.Right) { dir = Vector3.right; } else { dir = Vector3.left; } // cast ray RaycastHit hit; Physics.Raycast(transform.position, dir, out hit, pushpullDistance, Layers.PushPullable); if (Application.isEditor) { Debug.DrawRay(transform.position, dir * pushpullDistance, Color.red, 5f); } // Evaluate hit if (hit.collider) { //Debug.Log("Holding objecT: " + hit.collider.name); // Update player state currentState = PlayerState.PushingPulling; // Reset x velocity velocity.x = 0; // Cache pushing/pulling body pushpullObject = hit.transform.GetComponent <PushPullObject>(); //pushPullRigidBody = hit.transform.GetComponent<Rigidbody>(); pushpullObject.transform.SetParent(transform); // Set the pushing/pulling break distance pushpullBreakDistance = Vector3.Distance(pushpullObject.transform.position, transform.position); // Process interaction event to the push/pull object pushpullObject.OnPushPullStart(); // Animation animator.SetBool(isPushPullingHash, true); // Events if (OnPushPullStart != null) { OnPushPullStart(pushpullObject); } } } }
private void OnBackToMenu() { GameManager.TimeScale = 1f; currentState = PlayerState.Idle; transform.position = Vector3.zero; }
private void OnGameOver() { currentState = PlayerState.GameOver; Cursor.visible = true; Cursor.lockState = CursorLockMode.None; }
void Awake() { state = PlayerState.Alive; body = GetComponent <Rigidbody2D>(); }
private void showPromote() { playerState = PlayerState.AwaitPromote; promoteOption = PromoteOptions.Queen; }
private void cancel()//если esc { playerState = PlayerState.Idle; holdedNode = null; }
public void SetState(PlayerState state) { this.state = state; }
public void SetState(PlayerState newState) { state = newState; }
public void Kill() { state = PlayerState.Dead; _collider.isTrigger = true; }
void OnGround() { ZeroVelocity(); currentPlayerState = PlayerState.onground; }
void FixedUpdate() { if (_prevSelectedBehaviour != selectedBehaviour || _behaviour == null) { if (_behaviour != null) { Destroy(_behaviour); } System.Type type; switch (selectedBehaviour) { default: type = typeof(JumpingPlayerBehaviour); break; } _behaviour = gameObject.AddComponent(type) as AbstractPlayerBehaviour; } if (_doDoubleJump) { _doDoubleJump = false; _behaviour.doDoubleJump = true; } switch (state) { case PlayerState.Idle: //Do Nothing break; case PlayerState.Dead: if (_prevState != state) { transform.Rotate(Vector3.forward, 180); } break; case PlayerState.Grounded: if (isImmortal) { isImmortal = false; } // StopCoroutine(JumpAnimation()); //StartCoroutine(JumpAnimation()); _groundedWait = false; _canDoubleJump = true; _behaviour.GroundedBehaviour(); break; case PlayerState.InAir: if (_prevState != state) { _animator.SetFloat(ANIM_FORCE, 0.5f); } if (mRigidbody.velocity.y <= 0) { state = PlayerState.Falling; } _behaviour.InAirBehaviour(); if (!_animationSet && mRigidbody.velocity.y <= 0.5f) { _animationSet = true; _animator.SetFloat(ANIM_FORCE, 1); } break; case PlayerState.Falling: _animationSet = false; _behaviour.FallingBehaivour(); if (!_groundedWait && CheckGroundCollision()) { _groundedWait = true; _animator.SetFloat(ANIM_FORCE, 0); StopCoroutine(GroundedWait()); StartCoroutine(GroundedWait()); } break; } if (transform.position.x < _areaMinX) { transform.position = new Vector3(_areaMaxX, transform.position.y); } if (transform.position.x > _areaMaxX) { transform.position = new Vector3(_areaMinX, transform.position.y); } _prevState = state; _prevSelectedBehaviour = selectedBehaviour; if (direction != _prevDirection) { Vector3 newScale = transform.localScale; newScale.x = _defaultScaleX * direction; transform.localScale = newScale; } _prevDirection = direction; }
public Player(string playerID, PlayerState state) { PlayerID = playerID; CurrentState = state; }
// Use this for initialization void Start() { currentPlayerState = PlayerState.falling; rb = gameObject.GetComponent <Rigidbody2D>(); ResetClamp(); }
public override void Update(GameTime gameTime) { timeSinceBombPlant += gameTime.ElapsedGameTime.TotalSeconds; if (timeSinceBombPlant >= BOMB_INTERVAL) { bombActive = false; timeSinceBombPlant = 0; } KeyboardState ks = Keyboard.GetState(); //if (!bombActive) /*if (currnetlyUsingBomb < numberOfBomb) * { * if (ks.IsKeyDown(Keys.Space)) * { * //if() * //plant a bomb on the hero's currnet position * bombPosition = position; * currnetlyUsingBomb++; * bombActive = true; * //bomb. * } * }*/ if (this.Visible) { if (ks.IsKeyDown(Keys.Up)) { playerState = PlayerState.Jump; position.Y -= speed; } else if (ks.IsKeyDown(Keys.Down)) { playerState = PlayerState.Duck; position.Y += speed; } else if (ks.IsKeyDown(Keys.Right)) { playerState = PlayerState.WalkingRight; position.X += speed; } else if (ks.IsKeyDown(Keys.Left)) { playerState = PlayerState.WalkingLeft; position.X -= speed; } else { playerState = PlayerState.Idle; } } position.X = MathHelper.Clamp(position.X, 0, GraphicsDevice.Viewport.Width - textureIdle.Width); int playerHeight = playerState == PlayerState.Duck ? textureDuck[0].Height : textureIdle.Height; position.Y = MathHelper.Clamp(position.Y, 0, GraphicsDevice.Viewport.Height - playerHeight); // update our frame info timeSinceLastFrame += gameTime.ElapsedGameTime.TotalSeconds; if (timeSinceLastFrame > FRAME_RATE) { switch (playerState) { case PlayerState.Idle: currentFrame = 0; timeSinceLastFrame = 0; break; case PlayerState.WalkingLeft: case PlayerState.WalkingRight: if (++currentFrame >= WALK_FRAME_COUNT) { currentFrame = 0; timeSinceLastFrame = 0; } break; case PlayerState.Duck: if (++currentFrame >= JUMPDUCK_FRAME_COUNT) { currentFrame = 0; timeSinceLastFrame = 0; } break; case PlayerState.Jump: if (++currentFrame >= JUMPDUCK_FRAME_COUNT) { currentFrame = 0; timeSinceLastFrame = 0; } break; } } // here we make sure that we are not off screen, we // clap the value to between 0 and width of screen - texture width base.Update(gameTime); }
public Player SetState(PlayerState state) => new Player(PlayerID, state);
public void ForceEnterState(PlayerState newState) { CheckNewState(newState); }
public GameStateUtility() { playerState = new PlayerState(); }
public void SetPlayerState(PlayerState newPlayerState) { currentPlayerState = newPlayerState; }
void Update() { agent.SetDestination(moveTarget.transform.position); if (playerState != PlayerState.idle) { if (playerState == PlayerState.combat) { Vector3 relativePos = moveTarget.transform.position - playerMesh.transform.position; relativePos.y = 0; Quaternion rotation = Quaternion.LookRotation(relativePos); playerMesh.rotation = rotation; } else { Vector3 moveTargetTempPos = new Vector3(moveTarget.transform.position.x + extension.x, moveTarget.transform.position.y, moveTarget.transform.position.z + extension.z); Vector3 relativePos = moveTargetTempPos - playerMesh.transform.position; relativePos.y = 0; Quaternion rotation = Quaternion.LookRotation(relativePos); playerMesh.rotation = rotation; } } if (Input.GetMouseButtonDown(1)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, ignoreWhenNavigating)) { Debug.DrawLine(ray.origin, hit.point, Color.red, 2); lastidleTime = Time.time; if (hit.transform.tag == "Pickup") { playerState = PlayerState.pickup; itemTarget = hit.transform.gameObject; } else if (hit.transform.tag == "Combat") { playerState = PlayerState.combat; enemyTarget = hit.transform.parent.gameObject; } else { playerState = PlayerState.walk; } HandleAnimation(); startMarker = transform.position; endMarker = hit.point; endMarker.y = startMarker.y; moveTarget.transform.position = endMarker; extension = (moveTarget.transform.position - playerMesh.transform.position).normalized * 5; //UpdateTargetDir(); } } if (playerState == PlayerState.pickup && Vector3.Distance(transform.position, itemTarget.transform.position) < itemRange) { Destroy(itemTarget); itemTarget = null; playerState = PlayerState.walk; //ConvertToUI(); } else if (playerState == PlayerState.combat || playerState == PlayerState.inCombat) { if (enemyTarget) { if (enemyTarget.GetComponent <EnemyAttack>().currentHealth > 0) { if (Attack()) { playerState = PlayerState.inCombat; //HandleAnimation(); } } else { playerState = PlayerState.walk; } } else { playerState = PlayerState.walk; } } else if (playerState == PlayerState.walk) { if (agent.velocity.magnitude <= 0.1f) { if (Time.time - lastidleTime > idleTimeMin) { playerState = PlayerState.idle; //HandleAnimation(); lastidleTime = Time.time; } } } //print(playerState); if (!agent.pathPending) { if (agent.remainingDistance <= agent.stoppingDistance) { if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f) { //playerState = PlayerState.idle; } } } HandleAnimation(); }
public void PreBlock() { playerState = PlayerState.block; }
public ConnectedPlayer(string name) { this.name = name; currentPlayerState = PlayerState.OBSERVER; }
private void Start() { lastPlayerState = playerState; GetStateBehaviour(playerState)?.OnStateEnter(this); }
public PlayerStateChangedEventArgs(PlayerState state) { State = state; }
public void OnAttackSkill() { isOnSkill = true; PS = PlayerState.ATTACK1; }
private void Update() { if (isServer) { if (rigidBo.velocity.x > 0.00001f || rigidBo.velocity.x < -0.00001f) { flipstate = rigidBo.velocity.x > 0.00001f; } } spriteRenderer.flipX = flipstate; if (playerState != PlayerState.dead && health <= 0) { playerState = PlayerState.dead; animator.SetInteger("PlayerState", (int)playerState); rigidBo.isKinematic = true; cinemachineVC.Follow = null; cinemachineVC.LookAt = null; } if (playerState == PlayerState.dead || !isLocalPlayer) { return; } Vector3 lookatOffset = new Vector3(); float speedThreshold = 0.2f; float offset = 0.8f; if (rigidBo.velocity.x > speedThreshold) { lookatOffset.x = offset * transform.lossyScale.x; } else if (rigidBo.velocity.x < -speedThreshold) { lookatOffset.x = -offset * transform.lossyScale.x; } if (rigidBo.velocity.y > speedThreshold) { lookatOffset.y = offset * 0.4f * transform.lossyScale.y; } else if (rigidBo.velocity.y < -speedThreshold) { lookatOffset.y = -offset * 0.4f * transform.lossyScale.y; } lookAtPoint.transform.position = transform.position + lookatOffset; sinceKickTime += Time.deltaTime; sincePunchTime += Time.deltaTime; sinceJump += Time.deltaTime; if (playerState == PlayerState.jumping && rigidBo.velocity.y > 0.0f) { playerState = PlayerState.jumping; } else if ((playerState == PlayerState.jumping || playerState == PlayerState.idle) && rigidBo.velocity.y < 0.0f) { playerState = PlayerState.falling; } else if (playerState == PlayerState.falling && rigidBo.velocity.y <= 0.01f && rigidBo.velocity.y >= -0.01f) { playerState = PlayerState.idle; } else if (playerState == PlayerState.walking && rigidBo.velocity.x <= 0.01f && rigidBo.velocity.x >= -0.01f) { playerState = PlayerState.idle; } else if (playerState == PlayerState.punch && sincePunchTime > punchSpeed) { playerState = PlayerState.idle; } else if (playerState == PlayerState.kick && sinceKickTime > punchSpeed) { playerState = PlayerState.idle; } animator.SetInteger("PlayerState", (int)playerState); }
public void SetMediaItem(IResourceLocator locator, string mediaItemTitle, MediaItem mediaItem) { _mediaItem = mediaItem; // free previous opened resource FilterGraphTools.TryDispose(ref _resourceAccessor); FilterGraphTools.TryDispose(ref _rot); _state = PlayerState.Active; _isPaused = true; try { _resourceLocator = locator; _mediaItemTitle = mediaItemTitle; CreateResourceAccessor(); // Create a DirectShow FilterGraph CreateGraphBuilder(); // Add it in ROT (Running Object Table) for debug purpose, it allows to view the Graph from outside (i.e. graphedit) _rot = new DsROTEntry(_graphBuilder); // Add a notification handler (see WndProc) _instancePtr = IntPtr.Zero; if (_me != null) { _me.SetNotifyWindow(SkinContext.Form.Handle, WM_GRAPHNOTIFY, _instancePtr); } // Create the Allocator / Presenter object AddPresenter(); ServiceRegistration.Get <ILogger>().Debug("{0}: Adding audio renderer", PlayerTitle); AddAudioRenderer(); ServiceRegistration.Get <ILogger>().Debug("{0}: Adding preferred codecs", PlayerTitle); AddPreferredCodecs(); ServiceRegistration.Get <ILogger>().Debug("{0}: Adding source filter", PlayerTitle); AddSourceFilter(); ServiceRegistration.Get <ILogger>().Debug("{0}: Set subtitle renderer", PlayerTitle); SetSubtitleRenderer(); ServiceRegistration.Get <ILogger>().Debug("{0}: Adding subtitle filter", PlayerTitle); AddSubtitleFilter(true); ServiceRegistration.Get <ILogger>().Debug("{0}: Run graph", PlayerTitle); //This needs to be done here before we check if the evr pins are connected //since this method gives players the chance to render the last bits of the graph OnBeforeGraphRunning(); // Now run the graph, i.e. the DVD player needs a running graph before getting informations from dvd filter. int hr = _mc.Run(); new HRESULT(hr).Throw(); _initialized = true; OnGraphRunning(); } catch (Exception) { Shutdown(); throw; } }
protected override void OnTarget(Mobile from, object targeted) { if (GuildGump.BadMember(this.m_Mobile, this.m_Guild)) { return; } if (targeted is Mobile) { Mobile m = (Mobile)targeted; PlayerState guildState = PlayerState.Find(this.m_Guild.Leader); PlayerState targetState = PlayerState.Find(m); Faction guildFaction = (guildState == null ? null : guildState.Faction); Faction targetFaction = (targetState == null ? null : targetState.Faction); if (!m.Player) { this.m_Mobile.SendLocalizedMessage(501161); // You may only recruit players into the guild. } else if (!m.Alive) { this.m_Mobile.SendLocalizedMessage(501162); // Only the living may be recruited. } else if (this.m_Guild.IsMember(m)) { this.m_Mobile.SendLocalizedMessage(501163); // They are already a guildmember! } else if (this.m_Guild.Candidates.Contains(m)) { this.m_Mobile.SendLocalizedMessage(501164); // They are already a candidate. } else if (this.m_Guild.Accepted.Contains(m)) { this.m_Mobile.SendLocalizedMessage(501165); // They have already been accepted for membership, and merely need to use the Guildstone to gain full membership. } else if (m.Guild != null) { this.m_Mobile.SendLocalizedMessage(501166); // You can only recruit candidates who are not already in a guild. } #region Factions else if (guildFaction != targetFaction) { if (guildFaction == null) { this.m_Mobile.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild. } else if (targetFaction == null) { this.m_Mobile.SendLocalizedMessage(1013026); // That player must be in a faction before joining this guild. } else { this.m_Mobile.SendLocalizedMessage(1013028); // That person has a different faction affiliation. } } else if (targetState != null && targetState.IsLeaving) { // OSI does this quite strangely, so we'll just do it this way this.m_Mobile.SendMessage("That person is quitting their faction and so you may not recruit them."); } #endregion else if (this.m_Mobile.AccessLevel >= AccessLevel.GameMaster || this.m_Guild.Leader == this.m_Mobile) { this.m_Guild.Accepted.Add(m); } else { this.m_Guild.Candidates.Add(m); } } }
public void Push() { state = PlayerState.Push; animator.SetTrigger("Push"); }
public void OnIdel() { PS = PlayerState.IDEL; _isMove = false; }