void SetInitialStats(int phase, int level, int maxPhase)
    {
        EnemyStatus       enemyStatus       = GetComponent <EnemyStatus>();
        VampireController vampireController = GetComponent <VampireController>();

        if (maxPhase > 0)
        {
            enemyStatus.SetMaxPhase(maxPhase);
        }
        else
        {
            if (level < 30)
            {
                enemyStatus.SetMaxPhase(1);
                maxPhase = 1;
            }
            else if (level < 60)
            {
                enemyStatus.SetMaxPhase(2);
                maxPhase = 2;
            }
            else
            {
                enemyStatus.SetMaxPhase(3);
                maxPhase = 3;
            }
        }
        enemyStatus.maxHealth = GetPhaseMaxHP(phase, level, maxPhase);
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        vampireController.SetPlayerTransform(player.transform);
    }
예제 #2
0
    // Update is called once per frame
    protected override void Update()
    {
        if (playerController != null)
        {
            VampireController vc = (VampireController)playerController;
            finalDirection = GetDirectionToTargetForMovement();

            if (vc.primaryCooldown.done && Mathf.Pow(vc.biteRange, 2) > closestHumanDistanceSqr)
            {
                vc.AIMove(directionToAttack);
                vc.AIUsePrimary();
            }
            // Do a dash as a vampire if you can slow the humans down, don't just waste it
            else if (vc.secondaryCooldown.done && Mathf.Pow(vc.GetDashDistance(), 2) > closestHumanDistanceSqr)
            {
                RaycastHit2D hitTarget = Physics2D.Raycast(playerController.GetPosition(), finalDirection, vc.GetDashDistance(), wallLayerMask);

                // Dash if there is no wall that the AI would crash into
                if (hitTarget.collider == null)
                {
                    // Don't dash if you would overshoot a light you want to turn off
                    if (closestLightDistanceSqr > Mathf.Pow(vc.GetDashDistance(), 2))
                    {
                        playerController.AIUseSecondary();
                    }
                }
            }

            if (finalDirection.sqrMagnitude > 0.01f)
            {
                playerController.AIMove(finalDirection);
            }
        }
    }
예제 #3
0
    void Start()
    {
        if (_instance != null)
        {
            Debug.LogError("There should not be two vampire controllers");
        }
        _instance = this;

        SpawnPlayer(new Vector3(10f, 10f, 0f));
    }
 void Awake()
 {
     vampireController = GetComponent <VampireController>();
 }