// Use this for initialization void Start() { if (characterType == null) { characterType = GetComponent <MindControlType>(); } ph = GameObject.Find("PlayHud").transform.GetComponent <HUDstate>(); if (characterType.GetComponent <MindControlType>()) { ph.Hypno(); } else if (characterType.GetComponent <TeleportType>()) { ph.Teleport(); } else if (characterType.GetComponent <BrawlerType>()) { ph.Hypno(); } else if (characterType.GetComponent <GunnerType>()) { ph.Hypno(); } animator = GetComponent <Animator>(); speed = characterType.GetMoveSpeed() + GlobalMoveSpeed.GetSpeedDelta(); prevPos = transform.position; hp = characterType.GetHP(); if (name != null) { name.text = characterType.name; } }
void StateHandler() { // This will change state from patrol or search to chase if ((state == 0 || state == 3) && SeePlayer()) { state = 1; pathFollower.speed = 3 + GlobalMoveSpeed.GetSpeedDelta(); pathFollower.shouldMove = true; } // This keeps track of vision with player, will change state to search if (state == 1 || state == 3) { if (sw.Elapsed.Seconds == 0) { if (!PlayerVision()) { sw.Start(); } } else if (sw.Elapsed.Seconds > giveUpTime) { sw.Stop(); sw.Reset(); if (!PlayerVision() && lastKnown == null) { // Set the seeking transform to player's last known location and whatnot lastKnown = new GameObject("Player's Last Known Location").transform; lastKnown.position = pathfinding.target.position; pathfinding.target = lastKnown; state = 3; pathFollower.speed = 1.5f + GlobalMoveSpeed.GetSpeedDelta(); } } } switch (state) { case 0: Patrol(); break; case 1: Chase(); break; case 2: Attack(); break; case 3: Search(); break; default: Patrol(); break; } }
// Use this for initialization void Start() { movespeed = 3 + GlobalMoveSpeed.GetSpeedDelta(); name = "Hypno"; //overwrite movespeed and hp here. hp = 1; //setting melee }
void Attack() { if (updateAttack) { // Attack the player // For melee type if (!charType.isSpecial && charType.isMelee && !charType.isRanged) { if (Time.time % 10 > 5f) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else { charType.Tertiary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } } // For ranged type else if (!charType.isSpecial && charType.isMelee && charType.isRanged) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } // For teleport type else if (charType.isSpecial && charType.isMelee && charType.isRanged) { if (Time.time % 10 > 7f) { charType.Primary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else if (Time.time % 10 > 6f) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else { charType.Tertiary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } } StartCoroutine(PauseAttack(attackWait)); } // If we're too far away from the player go back and chase them again if (Vector2.Distance(pathfinding.target.position, myTrans.position) > attackDistance) { print("I should chase."); state = 1; pathFollower.speed = 3 + GlobalMoveSpeed.GetSpeedDelta(); pathFollower.shouldMove = true; } }
IEnumerator SearchWait(float pauseLength) { updateSearch = false; yield return(new WaitForSeconds(pauseLength)); updateSearch = true; if (PlayerVision()) { print("Found you!! Time to chase."); state = 1; pathFollower.speed = 3f + GlobalMoveSpeed.GetSpeedDelta(); pathfinding.target = player.transform; } else { print("Can't find them, guess I should head back to my post."); state = 0; pathFollower.speed = 1f + GlobalMoveSpeed.GetSpeedDelta(); lastKnown = null; DestroyImmediate(GameObject.Find("Player's Last Known Location")); } yield return(null); }
void UpdateAnimationVars() { animator.SetFloat("x_mov", (GlobalMoveSpeed.GetSpeedDelta() + speed) * Input.GetAxis("Horizontal")); animator.SetFloat("y_mov", (GlobalMoveSpeed.GetSpeedDelta() + speed) * Input.GetAxis("Vertical")); }
//basic movement. Might make this check to see if it's doing stuff but idk void Move() { transform.Translate(new Vector3((GlobalMoveSpeed.GetSpeedDelta() + speed) * Input.GetAxis("Horizontal") * Time.deltaTime, (GlobalMoveSpeed.GetSpeedDelta() + speed) * Input.GetAxis("Vertical") * Time.deltaTime)); }
public float GetMoveSpeed() { return(movespeed + GlobalMoveSpeed.GetSpeedDelta()); }