public void ChangeState(IdolState s, Fsm fsm) { DebugUtils.Assert(fsm != null, "Can't translate to a null npc state!"); currentFsm.OnExit(); currentFsm = fsm; state = s; DebugUtils.LogWarning(DebugUtils.Type.AI_Npc, string.Format("{0} {1} enter {2} state", npcType, id, state)); currentFsm.OnEnter(); }
void Start() { currentState = IdolState.WAITING; float stamPercent = (float)currentStamina / maxStamina; staminaMeter.transform.localScale = new Vector3(Mathf.Clamp(stamPercent, 0, 1), 1, 1); float spiritPercent = (float)currentSpirit / maxSpirit; spiritMeter.transform.localScale = new Vector3(Mathf.Clamp(spiritPercent, 0, 1), 1, 1); staminaText.text = currentStamina + " / " + maxStamina; spiritText.text = currentSpirit + " / " + maxSpirit; head = transform.Find("Head"); body = transform.Find("Body"); armLeft = transform.Find("Arm left"); hand = armLeft.Find("Hand"); armRight = transform.Find("Arm right"); headSprites = Resources.LoadAll <Sprite>(headFile); bodySprites = Resources.LoadAll <Sprite>(bodyFile); head.GetComponent <SpriteRenderer>().sprite = headSprites[2]; body.GetComponent <SpriteRenderer>().sprite = bodySprites[1]; hand.GetComponent <SpriteRenderer>().sprite = micSprite; skills = new Skill[5]; Skill skill = new Skill(this, Skill.ActionType.SING, baseDrive, baseAlignment, profileImage); skills[0] = skill; skill = new Skill(this, Skill.ActionType.DANCE, baseDrive, baseAlignment, profileImage); skills[1] = skill; skill = new Skill(this, Skill.ActionType.CROWD_BOOST, baseDrive, baseAlignment, profileImage); skills[2] = skill; skill = new Skill(this, Skill.ActionType.DANCE, Skill.Drive.KNOWLEDGE, baseAlignment, profileImage); skills[3] = skill; skill = new Skill(this, Skill.ActionType.SING, Skill.Drive.FAME, baseAlignment, profileImage); skills[4] = skill; }
public void Initialize(long id, NpcData proto, FixVector3 p, FixVector3 r) { this.id = id; type = LogicUnitType.Idol; position = p; transform.position = p.vector3; brithPosition = p; brithDirection = r; hurtType = AttackPropertyType.PhysicalAttack; npcProto = proto; metaId = proto.ID; iconId = -1; modelId = proto.ModelID; modelRadius = ConvertUtils.ToLogicInt(proto.ModelRadius); npcType = (NpcType)proto.NPCType; attackType = (NpcAttackType)proto.StandardAttack; rebornInterval = ConvertUtils.ToLogicInt(proto.RebornInterval); physicasAttack = (int)proto.PhysicsAttack; armor = (int)proto.Armor; magicResist = (int)proto.MagicResist; speedFactor = proto.Speed; healthRegen = proto.HealthRegen; maxHp = proto.Health; chaseArea = proto.TargetDetectRange; maxChaseDistance = proto.MaxChaseDistance; emberOutPut = proto.EmberOutPut; projectileId = proto.ProjectileId; attackRange = proto.AttackRange; killReward = proto.KillReward; fightInterval = 1; hp = maxHp; damage = physicasAttack; InitializeState(); state = IdolState.IDLE; currentFsm = fsmIdle; ChangeState(IdolState.IDLE, fsmIdle); }
void Update() { switch (currentState) { case IdolState.WAITING: break; case IdolState.ACTION: if (perform()) { currentState = IdolState.WAITING; } break; case IdolState.FAINTED: break; } }
public void readyPerformance(Skill perform) { performing = perform; currentState = IdolState.ACTION; }