private void Decide() { switch (type) { case NodeType.pee: target = FindTarget(NodeType.pee); break; case NodeType.food: target = FindTarget(NodeType.food); break; case NodeType.sleep: target = FindTarget(NodeType.sleep); break; default: target = FindTarget(NodeType.standard); break; } if (current != target) { FindPath(current, target); action = CatAction.walking; } }
private void Walk() { Vector3 dir = path[0].transform.position + path[0].offset - transform.position; dir.Normalize(); GetComponent <SpriteRenderer>().flipX = dir.x < 0f; transform.position += dir / 6f; if (Vector3.Distance(transform.position, path[0].transform.position + path[0].offset) < 1f) { if (path[0] == target) { if (target.type == NodeType.standard) { action = CatAction.idle; } else { action = CatAction.busy; busyTimer = 1f; } } current = path[0]; path.RemoveAt(0); } }
// ----------------------------------------------------------------- public void Init(CatAction action, OnActionButtonClickDelegate OnActionButtonClick) { this.action = action; this.OnActionButtonClick = OnActionButtonClick; textFieldCaption.text = CatStrings.GetByAction(action);; }
private int GetTicketsForAction(CatAction action) { switch (action.frequency) { case ActionFrequency.Common: return(3); case ActionFrequency.Rare: return(1); } return(0); }
// ----------------------------------------------------------------- public void ProcessAction(CatAction action) { CatActionReaction reaction = catActionsTable.GetCatActionReaction(new CatActionTableKey(currentMood, action)); if (reaction.newMood != null) { currentMood = (CatMood)reaction.newMood; } infoPanel.SetMood(currentMood); infoPanel.SetReaction(reaction.reaction); }
// ----------------------------------------------------------------- public static string GetByAction(CatAction action) { switch (action) { case CatAction.PLAY: return("Поиграть"); case CatAction.FEED: return("Накормить"); case CatAction.CARESS: return("Погладить"); case CatAction.KICK: return("Дать пинка"); default: throw new Exception("Error: No such CatAction in strings"); } }
private void SetAction(CatAction catAction) { _catActions = catAction; switch (_catActions) { case CatAction.Walking: _catMove.ChangeWalkState(WalkingState.Walk); break; case CatAction.Buys: _catMove.ChangeWalkState(WalkingState.Stand); _catMove.WalkToPoint(_catSpawner.VendingPosition(VendingType.Coffee)); _spawnCoin.SpawnCoins(); break; case CatAction.Leaves: _catMove.Leave(); break; } }
private IEnumerator TakeAction(float castRate) { CatAction toPerform = intentions[0]; MovingTextManager.Instance.ShowMessage(toPerform.abilityTitle, transform.position, Color.white); if (toPerform.soundEffect != null) { audioSource.clip = toPerform.soundEffect; audioSource.Play(); } takingAction = true; yield return(toPerform.Perform(firePoint, castRate, this)); takingAction = false; intentions.RemoveAt(0); moveIntentions.RemoveAt(0); AddIntention(); DrawIntentions(); movingTowards = moveIntentions[0]; }
private void Update() { switch (action) { case CatAction.idle: sr.sprite = sprites[1]; decideTime -= Time.deltaTime; if (decideTime <= 0f) { decideTime = Random.Range(3f, 6f); Decide(); } break; case CatAction.busy: sr.sprite = sprites[1]; float time = 1f; switch (type) { case NodeType.food: time = 5f; needs[0].value = 1f; break; case NodeType.pee: time = 5f; needs[1].value = 1f; break; case NodeType.sleep: time = 2f; needs[2].value = 1f; break; } if (current.ready) { busyTimer -= Time.deltaTime / time; if (busyTimer <= 0f) { action = CatAction.idle; type = NodeType.standard; current.Use(); decideTime = 1f; } } else { Debug.Log("Complain"); } break; case CatAction.walking: sr.sprite = sprites[0]; if (path.Count > 0) { Walk(); } break; } }
// ----------------------------------------------------------------- public CatActionTableKey(CatMood mood, CatAction action) { this.action = action; this.mood = mood; }
public void SetNextIntention(CatAction nextAction) { intentions[1] = nextAction; DrawIntentions(); }
public void Start() { cat = GetComponent <Cat>(); nextAction = GetComponents <CatAction>().First(action => action.abilityTitle == nextIntention); }
public DirectionalCatAction(CatAction action, Vector3 direction) { Action = action; Direction = direction; }
// ----------------------------------------------------------------- void OnActionButtonClick(CatAction action) { catController.ProcessAction(action); }