/// <summary> /// 新建函数 /// </summary> /// <param name="c"></param> public void Copy(CharaPrefab c) { m_CharaState = new CharaState(c.m_CharaState); m_charaBackGroundInformation = new CharaBackGroundInformation(c.m_charaBackGroundInformation); m_CharaAttackData = new CharaAttackData(c.m_CharaAttackData); m_CharaState.CurrentEmotion = m_CharaState.MaxEmotion; }
void Start() { state = CharaState.Idle; humanAnimation.Play("Default"); // 敢えて書いておく eggMan.OnJumpTop += JumpTop; eggMan.OnJumpEnd += JumpEnd; }
void JumpEnd() { state = CharaState.Idle; humanAnimation.Play("Default"); moveSpeed = 0.0F; move = false; }
//转换角色状态 public void ChangeCharaState(CharaState _state) { characterstate = _state; #if _Debug Debug.Log("change characterstate:" + _state.ToString()); #endif }
public CharaState(CharaState cs) { maxHealth = cs.maxHealth; currentHealth = cs.currentHealth; MaxEmotion = cs.maxHealth; CurrentEmotion = cs.CurrentEmotion; }
void Idle() { if (state == CharaState.Jump || state == CharaState.Spinig) { return; } state = CharaState.Idle; humanAnimation.Play("Default"); }
// Use this for initialization void Start() { manager = GameObject.Find("GameManager"); dir = Direction.Right; state = CharaState.Fall; detector = new bool[6]; isWalk = false; isClimb = false; }
void JumpTop() { state = CharaState.Fall; // move var currentPos = humanTransform.position; moveTo = new Vector3(currentPos.x, 0.0F, currentPos.z); moveSpeed = jumpSpeed; move = true; }
public ObjState(CharaState chara) { name = chara.name; MaxHp = chara.MaxHp; Hp = MaxHp; Atk = chara.Atk; Def = chara.Def; Agi = chara.Agi; NextLebel = chara.NextLebel; }
void Squat() { if (state == CharaState.Jump || state == CharaState.Fall) { return; } state = CharaState.Squat; humanAnimation.Play("Squat"); moveSpeed = 0.0F; move = false; }
void Idle() { if (state == CharaState.Jump || state == CharaState.Fall || state == CharaState.Squat) { return; } state = CharaState.Idle; humanAnimation.Play("Default"); moveSpeed = 0.0F; move = false; }
void Jump() { if (state == CharaState.Jump || state == CharaState.Fall) { return; } state = CharaState.Jump; humanAnimation.Play("Jump"); // move var currentPos = humanTransform.position; moveTo = new Vector3(currentPos.x, 1.0F, currentPos.z); moveSpeed = jumpSpeed; move = true; }
//****************************************************** /// <summary> /// スプライト、「Turn」か「Ok」か切り替える /// </summary> /// <param name="state">フレームの状態を受け取る</param> //****************************************************** private void setActiveState(CharaState state) { //スタンバイ状態のとき if (state == CharaState.Standby) { ok.SetActive(true); turn.SetActive(false); } //ノーマルとウェイト状態のとき else { ok.SetActive(false); turn.SetActive(true); } }
public override void HitChara(Character character) { if (character is Attack) { if (CheckDirection(character) == Direction.Right) { direction = Direction.Right; } if (CheckDirection(character) == Direction.Left) { direction = Direction.Left; } state = CharaState.Damage; //isDeadFlag = true; } }
public Enemy(string name, Vector2 position, AIName aiName, GameDevice gameDevice, IGameObjectMediator mediator) : base(name, position, 64, 64, 55, 60, gameDevice) { this.Position = position; this.aiName = aiName; this.mediator = mediator; map = mediator.GetMap(); damageTimer = new CountDownTimer(0.5f); gravity = 0.5f; damageVelocityY = -5; state = CharaState.Normal; SetAI(); //【追加】モーションの生成・追加 motionDict = new Dictionary <MotionName, Util.Motion>() { { MotionName.attack, new Motion(new Range(0, 4), new CountDownTimer(0.25f)) }, { MotionName.move, new Motion(new Range(0, 4), new CountDownTimer(0.15f)) }, { MotionName.idling, new Motion(new Range(0, 4), new CountDownTimer(0.25f)) }, }; for (int i = 0; i <= 4; i++) { motionDict[MotionName.attack].Add(i, new Rectangle(new Point(64 * i, 0), new Point(64))); } for (int i = 0; i <= 4; i++) { motionDict[MotionName.move].Add(i, new Rectangle(new Point(64 * i, 0), new Point(64))); } for (int i = 0; i <= 4; i++) { motionDict[MotionName.idling].Add(i, new Rectangle(new Point(64 * i, 0), new Point(64))); } //最初のモーションはムーブに設定 currentMotion = motionDict[MotionName.move]; //【追加】移動方向の設定 myDirectionX = Direction.Right; myDirectionY = Direction.Top; }
private void AI() { if (!detector[0]) { //落下途中止まらないためにx座標修正 float x = (int)(transform.position.x / 0.64f); x += (transform.position.x > 0) ? 0.5f : -0.5f; transform.position = new Vector3(x * 0.64f, transform.position.y, transform.position.z); state = CharaState.Fall; isWalk = false; isClimb = false; return; } if (detector[3] && detector[5]) { ReverseDir(); } if (detector[3] && !detector[5]) { Jump(0.7f, 4.3f); state = CharaState.JumpUp; isWalk = true; isClimb = false; return; } if (!detector[3] && !detector[5] && !detector[1] && detector[2]) { Jump(2.1f * speed, 2.5f); state = CharaState.JumpForward; isWalk = true; isClimb = false; return; } state = CharaState.MoveForward; isWalk = true; isClimb = false; }
void RunRight() { if (state == CharaState.Jump || state == CharaState.Spinig) { return; } // 左を向いているので右を向く if (filipedLelt) { FlipHuman(); } state = CharaState.RunRight; humanAnimation.Play("Run"); // move var currentPos = humanTransform.position; var moveTo = new Vector3( (currentPos.x + runUnit >= edgeX) ? edgeX : currentPos.x + runUnit, // 端を超えないように currentPos.y, currentPos.z); humanTransform.position = Vector3.MoveTowards(currentPos, moveTo, Time.deltaTime * runSpeed); }
private void DamageUpdate(GameTime gameTime) { damageTimer.Update(gameTime); if (direction == Direction.Right) { Position += new Vector2(10, damageVelocityY); } else if (direction == Direction.Left) { Position += new Vector2(-10, damageVelocityY); } damageVelocityY += gravity; if (damageTimer.IsTime()) { damageTimer.Initialize(); state = CharaState.Delete; damageVelocityY = -5; } }
public ChangeSprite frameSprite; ///<オブジェクト保存用の変数 //********************************************************** /// <summary> /// キャラクターのフレームを設定する /// </summary> /// <param name="state">キャラクターの状態を受け取る</param> //********************************************************** public void SetFrameState(CharaState state) { switch (state) { //ノーマル状態の場合 case CharaState.Normal: setActiveState(state); break; //スタンバイ状態の場合 case CharaState.Standby: setActiveState(state); break; //ウェイト状態の場合 case CharaState.Wait: setActiveState(state); break; } frameSprite.SetSprite((int)state); }
void RunLeft() { if (state == CharaState.Jump || state == CharaState.Fall) { return; } // 右を向いているので左を向く if (!filipedLelt) { FlipHuman(); } state = CharaState.RunLeft; humanAnimation.Play("Run"); // move var currentPos = humanTransform.position; moveTo = new Vector3( (currentPos.x - runUnit <= -edgeX) ? -edgeX : currentPos.x - runUnit, // 端を超えないように currentPos.y, currentPos.z); moveSpeed = runSpeed; move = true; }
// --------------------- public void PerformUseAction() { this.charaState = CharaState.USE; this.charaAnim.CrossFade(this.ANIM_IDLE, 0.3f); // idle on base layer this.charaAnim.CrossFade(this.ANIM_USE, 0.3f, PlayMode.StopSameLayer); // use on it's own layer this.useElapsed = 0; //Debug.Log("[" + Time.frameCount + "] USE!"); // Play sound effect... AudioSource audioSource = this.GetComponent <AudioSource>(); if ((this.actionSound != null) && (audioSource != null)) { audioSource.PlayOneShot(this.actionSound); } // look for useable items in range! }
public void Climb() { isClimb = true; state = CharaState.MoveUp; }
// -------------------- public void StartWalking() { this.charaState = CharaState.WALK; this.charaAnim.CrossFade(this.ANIM_WALK_F, 0.3f); }
// ------------------- public void StartRunning() { this.charaState = CharaState.RUN; this.charaAnim.CrossFade(this.ANIM_RUN_F, 0.3f); }
// -------------------- public void StartIdle() { this.charaState = CharaState.IDLE; this.charaAnim.CrossFade(this.ANIM_IDLE, 0.3f); }
// --------------------- public void PerformUseAction() { this.charaState = CharaState.USE; this.charaAnim.CrossFade(this.ANIM_IDLE, 0.3f); // idle on base layer this.charaAnim.CrossFade(this.ANIM_USE, 0.3f, PlayMode.StopSameLayer); // use on it's own layer this.useElapsed = 0; //Debug.Log("[" + Time.frameCount + "] USE!"); // Play sound effect... if ((this.actionSound != null) && (this.audio != null)) this.audio.PlayOneShot(this.actionSound); // look for useable items in range! }
public void ChangeState(CharaState next) { _State = next; }
void Jump() { state = CharaState.Jump; humanAnimation.Play("Jump"); }
public void Copy(EnemyType enemy) { m_CharaState = new CharaState(enemy.m_CharaState); m_charaBackGroundInformation = new CharaBackGroundInformation(enemy.m_charaBackGroundInformation); m_CharaAttackData = new CharaAttackData(enemy.m_CharaAttackData); }
void JumpEnd() { state = CharaState.Idle; humanAnimation.Play("Default"); }
public void SetState(CharaState state) { this.state = state; }