private void Update() { if (dead) { return; } if (gameObject.CompareTag("Preview")) { return; } UnitActions.Move(this); UpdateMovingAnimation(); UnitActions.UpdateIsSwimming(this); updateCounter = (updateCounter + 1) % GameManager.gameManager.countsBetweenUpdates; if (updateCounter == 0) { UnitActions.SetThought(this); //UnitActions.WanderIfDeadTarget(this); UnitActions.HungerEffect(this); UnitActions.ThirstEffect(this); UnitActions.TurnHungryChance(this); UnitActions.TurnThirstyChance(this); UnitActions.TurnHornyChance(this); UnitActions.HealthRegenEffect(this); unitState = UnitStateMachine.NextState(this); } }
public void SetUpPanel() { SM = GetComponentInParent <UnitStateMachine>(); GetComponent <Image>().color = WaitColor; SM.ChangeStatusToMove += ChangeColorToMove; SM.ChangeStatusToIdle += ChangeColorToIdle; }
protected override void OnStateEnter() { base.OnStateEnter(); usm = (UnitStateMachine)stateMachine; engaging = Engage(usm.currentThreat); StartCoroutine(engaging); }
void TriggerAttack() { Debug.Log("Player is attacking " + gameObject.name); UnitStateMachine u = ScriptToolbox.GetInstance().GetPlayerManager().player.GetComponent <UnitStateMachine>(); u.currentThreat = transform; u.RequestChangeState(StateMachine.States.Fight); }
void TriggerTrade() { if (myShop != null) { UnitStateMachine u = GetComponent <UnitStateMachine>(); u.RequestChangeState(StateMachine.States.Shopping); } else { Debug.Log("This NPC cannot trade"); } }
protected override void Init() { base.Init(); usm = (UnitStateMachine)stateMachine; canTransitionInto = new StateMachine.States[] { StateMachine.States.Idle, StateMachine.States.Incapacitated, StateMachine.States.Routed }; }
// Start is called before the first frame update public void Start() { rb = GetComponent <Rigidbody2D>(); GetComponent <Damageable>().damageAction += (n) => rb.AddForce(15 * Mathf.Sign(n.transform.lossyScale.x) * Vector2.right, ForceMode2D.Impulse); GetComponent <Damageable>().dieAction += () => Destroy(gameObject); motion = GetComponent <MoveXCommand>(); attackCommand = GetComponent <ZombiAttack>(); stateMachine = GetComponent <UnitStateMachine>(); Patroler patroler = new Patroler(new StateInfo(transform, stateMachine), transform.position) { speed = BaseSpeed * 0.7f, time = 3f }; Follower follower = new Follower(new StateInfo(transform, stateMachine)) { maxSpeed = BaseSpeed }; MoveToPoint motionToPoint = new MoveToPoint(new StateInfo(transform, stateMachine), patroler.point, patroler) { speed = new Vector2(BaseSpeed * 0.8f, 0) }; //stateMachine.SetState(patroler); stateMachine.Initialize(follower); target = GameObject.FindGameObjectWithTag(targetTag).GetComponent <Rigidbody2D>(); follower.SetTarget(target); detectPlayer.Enter += () => stateMachine.SetState(follower); attackZone.Enter += () => stateMachine.SetState(new IdleState(new StateInfo(transform, stateMachine))); attackZone.Stay += () => attackCommand.Execute(); attackZone.Exit += () => stateMachine.SetState(follower); //lostZone.Exit += () => //{ // if (stateMachine.currentState == follower) // { // stateMachine.SetState(new WaitState(transform, stateMachine, 1, motionToPoint)); // } //}; }
protected override void OnStateEnter() { base.OnStateEnter(); usm = (UnitStateMachine)stateMachine; if (wander) { StartCoroutine(Wander()); } if (!doNotReact) { StartCoroutine(ScanArea()); } }
private void Update() { if (DebugTextBox == null) { return; } if (SM == null) { SM = GetComponent <UnitStateMachine>(); } DebugTextBox.SetText(SM.CurrentState.ToString()); }
protected override void OnStateEnter() { base.OnStateEnter(); UnitStateMachine usm = (UnitStateMachine)stateMachine; if (usm.unitTraits.courage <= Random.Range(0, 100)) //also check who's around to determine any other threats { stateMachine.RequestChangeState(StateMachine.States.Flight); } else { stateMachine.RequestChangeState(StateMachine.States.Fight); } }
public void StartDialogue(Dialogue dialogue) { isOpen = true; dialogueWindow.SetBool("isOpen", isOpen); nameText.text = dialogue.name; unitTalking = dialogue.unit; sentences.Clear(); //clear que of any old sentences foreach (string sentence in dialogue.sentences) { sentences.Enqueue(sentence); //adds sentances to our que } DisplayNextSentence(); }
// Start is called before the first frame update void Start() { stroke = GetComponent <MorticianStroke>(); charge = GetComponent <MorticianCharge>(); stateMachine = GetComponent <UnitStateMachine>(); Follower follower = new Follower(new StateInfo(transform, stateMachine)); player = GameObject.FindGameObjectWithTag("Player").transform; follower.SetTarget(player.GetComponent <Rigidbody2D>()); follower.maxSpeed = 4f; stateMachine.Initialize(follower); idle = new IdleState(new StateInfo(transform, stateMachine)); stroke.beginAttack += () => stateMachine.SetState(idle); stroke.endAttack += () => stateMachine.SetState(follower); }
public float bleedBonus = 0f; //how rapidly we bleed from this part private void Start() { //might not want these in bodyparts because they're going to get called in every single body part in the game! myBrain = GetComponent <Brain>(); myBody = GetComponent <BodyPartController>(); myCombatSkills = GetComponent <CombatSkills>(); anim = GetComponent <UnitAnimController>(); ai = GetComponent <UnitReactions>(); stateMachine = GetComponent <UnitStateMachine>(); if (dollPart != null) { dollPart.Initialize(PackagePartInfo()); } MyWeapon(); //run this to make sure we hve unarmed weapon //Debug.Log("assigning parts for " + this); //Debug.Log("my armortype is " + armorType); }
private void Start() //make private? { //unitReactions = GetComponent<UnitReactions>(); stateMachine = GetComponent <UnitStateMachine>(); anim = GetComponent <UnitAnimController>(); mySkills = GetComponent <CombatSkills>(); mySkills.onSkillGained += UpdateSkills; AddBodyParts(); //if a unit doesn't have an equipment manager load default eqpmnt EquipmentManager e = GetComponent <EquipmentManager>(); if (e == null) { GetComponent <DefaultEquipment>().EquipLoadout(this); } else { //let equipment handler load it's own default stuff if it needs to e.onEquipmentChanged += UpdateSkills; } }
private void Start() { psm = ScriptToolbox.GetInstance().GetPlayerManager().player.GetComponent <UnitStateMachine>(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.LabelField("Hello, editor"); UnitStateMachine state = this.target as UnitStateMachine; }
private void Update() { unitState = UnitStateMachine.NextState(this); }
//can be used for descriptions and observations as well void TriggerDialogue() { UnitStateMachine u = GetComponent <UnitStateMachine>(); u.RequestChangeState(StateMachine.States.Talking); }