本文整理汇总了C#中PlayerState类的典型用法代码示例。如果您正苦于以下问题:C# PlayerState类的具体用法?C# PlayerState怎么用?C# PlayerState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerState类属于命名空间,在下文中一共展示了PlayerState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Move
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
};
}
示例2: StepForward
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++;
}
示例3: Awake
protected override void Awake()
{
base.Awake();
State = PlayerState.Normal;
_audioSource = GetComponent<AudioSource>();
}
示例4: Update
// 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;
}
}
示例5: CancelAction
//Cancel the currently displayed action
public void CancelAction()
{
selectedUnit = null;
m_tiles.ClearSelectedTiles();
m_hud.HideUnitInfo();
e_playerState = PlayerState.Default;
}
示例6: Start
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>();
}
示例7: Start
void Start ()
{
player = GameObject.Find("Player");
playerState = player.GetComponent<PlayerState>();
ani = GetComponent<Animation>();
ani.Play("Idle");
}
示例8: Awake
// Use this for initialization
void Awake()
{
state = 3;
playerHealth = GameObject.Find("Player").GetComponent<PlayerState>();
spikes = transform.Find("spiketrap_spikes");
a = GetComponent<AudioSource>();
}
示例9: FixedUpdate
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);
}
}
示例10: GameOver
void GameOver()
{
ePS = PlayerState.DEATH;
SoundPlay(ESound.DEATH);
GM.GameOver();
}
示例11: SetState
private void SetState(PlayerState new_state)
{
if (this.currentState != null)
this.currentState.End ();
this.currentState = new_state;
this.currentState.Start ();
}
示例12: SafeState
// public LevelState level;
//Stats
// public float timePlayed = 0.0F;
public SafeState()
{
// current = new SafeState();
// allLevels = new List<LevelState>();
// level = new LevelState();
player = new PlayerState();
}
示例13: handleInput
void handleInput()
{
PlayerState state = playerState_.handleInput ();
if (state != null) {
playerState_ = state;
}
}
示例14: Start
// Use this for initialization
protected override void Start()
{
base.Start();
pController = GetComponent<PlayerControllerIso>();
pState = PlayerState.RUNNING;
canRoll = true;
}
示例15: Update
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);
}
}