void Start() { if (comment == null) { comment = GetComponentInChildren <RandomComment>(true); } comment.transform.parent.gameObject.SetActive(false); }
void Update() { /* Reminder about random chances. * float randValue = Random.value; * if (randValue < .45f) // 45% of the time * { * // Do Normal Attack 1 * } * else if (randValue < .9f) // 45% of the time * { * // Do Normal Attack 2 * } * else // 10% of the time * { * // Do Special Attack * } */ if (enableSimpleAI) { // If FPS=30, the chance of changing state is 6% per second. if (Random.value < .002f) { SwitchState(); } if (Random.value < .002f) { if (comment == null) { comment = GetComponentInChildren <RandomComment>(true); } comment.NewRandomComment(); } switch (currentState) { case State.Idle: // Does nothing. break; case State.Wandering: rayMovement.CharacterInput = new Vector2(moveSpeed * moveDirection, 0); break; case State.Seeking: // Seeking for player. break; case State.Chasing: rayMovement.CharacterInput = new Vector2(moveSpeed * moveDirection, 0); rayMovement.Run = true; break; } } Sight(); }
void Start() { //hivemind = FindObjectOfType<AdvancedHivemind>(); if (targetChar) { rc = targetChar.GetComponent <RandomComment>(); rm = targetChar.GetComponent <RayMovement>(); //targetChar.GetComponent<RayNPC>().enableSimpleAI = false; } }
void Update() { if (Input.GetKeyDown(keyKillCurrentCharacter)) { //hivemind.RemoveCharacter(hivemind.GetCurrentlyActiveCharacter()); CharacterManager.KillCharacter(CharacterManager.GetCurrentCharacterEntity()); } if (targetChar) { if (Input.GetKeyDown(keyWarpTargetToCurrent)) { WarpTargetToCurrent(); } if (Input.GetKeyDown(keyChangeCommentOfTargetChar)) { if (!rc) { rc = targetChar.GetComponentInChildren <RandomComment>(true); } commentNum++; if (commentNum >= rc.GetCommentCount()) { commentNum = 0; } rc.GetComment(commentNum); } if (Input.GetKey(keyMoveTargetCharLeft)) { dir = -1; } else if (Input.GetKey(keyMoveTargetCharRight)) { dir = 1; } else { dir = 0; } if (dir != 0) { if (targetChar.GetComponent <RayNPC>().enableSimpleAI) { targetChar.GetComponent <RayNPC>().enableSimpleAI = false; } } if (!targetChar.GetComponent <RayNPC>().enableSimpleAI) { rm.CharacterInput = new Vector2(dir, 0); rm.Run = Input.GetKey(keyRunWithTargetChar); } } else { targetChar = CharacterManager.instance.allCharacters[Random.Range(1, CharacterManager.instance.allCharacters.Count)].GetGameObject(); if (targetChar) { rc = targetChar.GetComponent <RandomComment>(); rm = targetChar.GetComponent <RayMovement>(); } } if (Input.GetKeyDown(keySpawnRandomCharacter)) { if (listOfCharacters.allCharacters.Count > 0) { SpawnRandomCharacter(true); } } if (Input.GetKeyDown(keySpawnRandomCharacterSomewhere)) { if (listOfCharacters.allCharacters.Count > 0) { SpawnRandomCharacter(false); } } float delta = Input.GetAxisRaw("Mouse ScrollWheel"); if (delta != 0 && allowCameraZoom) { FindObjectOfType <CameraController>().ChangeZoomLevelInstant(-delta); } }