예제 #1
0
파일: LevelUp.cs 프로젝트: emilizz1/RPG
 void Start()
 {
     healthSystem     = GetComponent <HealthSystem>();
     weaponSystem     = GetComponent <WeaponSystem>();
     specialAbilities = GetComponent <SpecialAbilities>();
     audioSource      = GetComponent <AudioSource>();
 }
예제 #2
0
        private void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem     = GetComponent <WeaponSystem>();
            bool         inWeaponCircle   = distanceToPlayer <= currentWeaponRange;
            bool         inChaseRing      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool         outsideChaseRing = distanceToPlayer > chaseRadius;

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();
            if (outsideChaseRing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseRing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                weaponSystem.AttackTarget(player.gameObject);
                state = State.attacking;
            }
        }
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Y))
            {
                Time.timeScale = 0;
            }

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currrentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();
            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                StartCoroutine(Patrol());
            }
            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }
            if (distanceToPlayer <= currrentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
            }
        }
예제 #4
0
 void InitializeComponents()
 {
     specialAbilities = GetComponent <SpecialAbilities>();
     healthSystem     = GetComponent <HealthSystem>();
     character        = GetComponent <Character>();
     weaponSystem     = GetComponent <WeaponSystem>();
 }
예제 #5
0
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                StartCoroutine(Patrol());
            }

            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }

            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player);
            }
        }
예제 #6
0
        void Update()
        {
            var playerHealth = player.GetComponent <HealthSystem>().healthAsPercentage;

            if (playerHealth <= Mathf.Epsilon)
            {
                StopAllCoroutines();
                return;
            }

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.CurrectWeaponConfig.MaxAttackRange;

            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol);
            }
            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer);
            }
            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
예제 #7
0
 void Start()
 {
     character = GetComponent <Character>();
     RegisterForMouseEvents();
     abilities    = GetComponent <SpecialAbilities>();
     weaponSystem = GetComponent <WeaponSystem>();
 }
예제 #8
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>(); // No performance issue

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            bool inWeaponRadius     = distanceToPlayer <= currentWeaponRange;
            bool inChaseRadius      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseRadius = distanceToPlayer > chaseRadius;

            if (inWeaponRadius)
            {
                StopAllCoroutines();
                state = State.attacking;
                transform.LookAt(player.gameObject.transform);
                weaponSystem.AttackTarget(player.gameObject);
                character.GetNavMeshAgent().Move(Vector3.zero);
                character.GetNavMeshAgent().velocity = Vector3.zero;
            }

            if (outsideChaseRadius)
            {
                StopAllCoroutines();
                //weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }

            if (inChaseRadius)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
        }
예제 #9
0
        public void Update()
        {
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);
            weaponSystem       = GetComponent <WeaponSystem>();
            currentWeaponRange = weaponSystem.GetWeaponConfig().GetMaxAttackRange();

            bool inWeaponCricle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseCircle = distanceToPlayer > chaseRadius;

            if (outsideChaseCircle && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCricle && state != State.attacking)
            {
                StopAllCoroutines();
                character.SetDestination(gameObject.transform.position);
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
예제 #10
0
 public void Start()
 {
     player       = FindObjectOfType <PlayerControl>();
     weaponSystem = GetComponent <WeaponSystem>();
     animator     = GetComponent <Animator>();
     character    = GetComponent <Character>();
 }
예제 #11
0
        private void Start()
        {
            player       = GameObject.FindWithTag(Constants.PLAYER_TAG).GetComponent <PlayerControl>();
            character    = GetComponent <Character>();
            weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetWeaponConfig().GetMaxAttackRange();
        }
예제 #12
0
        void Start()
        {
            character     = GetComponent <Character>();
            weaponSystem  = GetComponent <WeaponSystem>();
            abilitySystem = GetComponent <AbilitySystem>();

            SetInitialWinConditionVariables();
        }
예제 #13
0
        void Start()
        {
            character = GetComponent <Character>();
            RegisterMouseClick();


            specialAbilties = GetComponent <SpecialAbilities>();
            weaponSystem    = GetComponent <WeaponSystem>();
        }
예제 #14
0
        void Start()
        {
            abilities    = GetComponent <SpecialAbilities>();
            healthSystem = GetComponent <HealthSystem>();
            character    = GetComponent <Character>();
            weaponSystem = GetComponent <WeaponSystem>();

            SubscribeForMouseClickEvents();
        }
예제 #15
0
        void Start()
        {
            playerCharacter = GetComponent <Character>();
            playerAbilities = GetComponent <SpecialAbilities>();
            characterStats  = GetComponent <CharacterStats>();
            weaponSystem    = GetComponent <WeaponSystem>();

            RegisterForMouseEvents();
        }
예제 #16
0
        // Start is called before the first frame update
        private void Start()
        {
            RegisterForMouseEvents();
            // PutWeaponInHand(weaponInUse);

            abilities    = GetComponent <SpecialAbilities>();
            animator     = GetComponent <Animator>();
            character    = GetComponent <Character>();
            weaponSystem = GetComponent <WeaponSystem>();
        }
예제 #17
0
        // Start is called before the first frame update
        void Start()
        {
            weaponSystem = GameObject.FindWithTag(Constants.PLAYER_TAG).GetComponent <WeaponSystem>();
            audioSource  = GetComponent <AudioSource>();

            var weaponPrefab     = weaponConfig.GetWeaponPrefab();
            var weaponGameObject = Instantiate(weaponPrefab, transform.position, transform.rotation);

            weaponGameObject.transform.parent = transform;
        }
예제 #18
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            bool inWeaponCircle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadious;
            bool outsideChaseCircle = distanceToPlayer > chaseRadious;

            if (outsideChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();

                state = State.attacking;
                //state = State.attacking; si activo deja de funcionar el health del player
                weaponSystem.AttackTarget(player.gameObject);
            }

////////////////////////////////////////////////////
            // if (distanceToPlayer > chaseRadious && state != State.patrolling)
            // {
            //  StopAllCoroutines();
            //  weaponSystem.StopAttacking();
            //  StartCoroutine( Patrol() );
            // }
            // if (distanceToPlayer <= chaseRadious && state != State.chasing)
            // {
            //  StopAllCoroutines();
            //  weaponSystem.StopAttacking();
            //  StartCoroutine(ChasePlayer());
            // }
            // if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            // {
            //  StopAllCoroutines();
            //  //state = State.attacking; si activo deja de funcionar el health del player
            //  weaponSystem.AttackTarget(player.gameObject);
            // }
///////////////////////////////////////////////////////
        }
예제 #19
0
        private void Start()
        {
            weaponSystem = GetComponent <WeaponSystem>();
            character    = GetComponent <Character>();
            abilities    = GetComponent <SpecialAbilities>();

            chatBox = FindObjectOfType <ChatBox>();
            chatBox.AddChatEntry("You: I'm almost back to the village.");
            chatBox.AddChatEntry("You: What is that fort doing up ahead?");

            RegisterForMouseEvent();
        }
예제 #20
0
        private void Start()
        {
            player         = GameObject.FindGameObjectWithTag("Player");
            characterStats = GetComponent <CharacterStats>();
            weaponSystem   = GetComponent <WeaponSystem>();
            enemyCharacter = GetComponent <Character>();
            enemyAbilities = GetComponent <SpecialAbilities>();

            spawnPosition = new GameObject("SpawnPosition");
            spawnPosition.transform.position = transform.position;
            spawnPosition.transform.parent   = GameObject.Find("SpawnPositions").transform;
        }
예제 #21
0
        private void OnTriggerEnter()
        {
            PlayerControl player = FindObjectOfType <PlayerControl>();

            WeaponSystem weapon = player.GetComponent <WeaponSystem>();

            weapon.PutWeaponInHand(weaponConfig);
            var audioSource = GetComponent <AudioSource>();

            audioSource.PlayOneShot(pickUpSFX);
            GetComponent <CapsuleCollider>().enabled = false;
            //Destroy(gameObject);
        }
예제 #22
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag == "Player" && hasPlayed == false)
            {
                hasPlayed = true;
                WeaponSystem weaponSystem = other.gameObject.GetComponent <WeaponSystem>();

                weaponSystem.PutWeaponInHand(weaponConfig);
                var audioSource = weaponSystem.GetComponent <AudioSource>();
                audioSource.clip = weapongPickUpSoundEffect;
                audioSource.Play();
                Destroy(this.gameObject);
            }
        }
예제 #23
0
        void Start()
        {
            weaponSystem = GetComponent <WeaponSystem>();
            npcMovement  = GetComponent <NPCMovement>();
            healthSystem = GetComponent <HealthSystem>();
            player       = FindObjectOfType <PlayerControl>();
            playerObj    = player.gameObject;

            if (weaponSystem != null)
            {
                attackRadius = weaponSystem.GetWeaponInUse().GetWeaponAttackRange();
            }

            returningPosition = transform.position;
        }
예제 #24
0
        void Start()
        {
            player       = FindObjectOfType <PlayerControl>().gameObject;
            weaponSystem = GetComponent <WeaponSystem>();
            character    = GetComponent <Character>();
            healthSystem = GetComponent <HealthSystem>();

            var      overrideController = GetComponent <Character>().OverrideController;
            Animator animator           = GetComponent <Animator>();

            animator.runtimeAnimatorController = overrideController;

            if (weaponSystem.GetCurrWeapon() != null)
            {
                currWeaponRange = weaponSystem.GetCurrWeapon().MaxAttackRange;
            }
        }
예제 #25
0
        private void Start()
        {
            character = GetComponent <Character>();
            Health    = GetComponent <Health>();
            Health.onDeathListeners += OnDeath;
            player             = FindObjectOfType <Player>();
            weaponSystem       = GetComponent <WeaponSystem>();
            currentWeaponRange = weaponSystem.CurrentWepaon.GetAttackRange();
            originalPosition   = transform.position;

            if (patrolPath)
            {
                iterator = patrolPath.GetNewIterator();
                state    = States.Patroling;
                character.SetTarget(patrolPath.GetFirstWaypoint());
                Patrol();
            }
        }
예제 #26
0
        private void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            attackRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToTarget = Vector3.Distance(playerControl.transform.position, transform.position);

            bool inWeaponRange     = distanceToTarget <= attackRange;
            bool inChaseRange      = distanceToTarget > attackRange && distanceToTarget <= chaseRadius;
            bool outsideChaseRange = distanceToTarget > chaseRadius;

            if (outsideChaseRange && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseRange && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(playerControl.gameObject);
            }
            if (isFriendly && distanceToTarget <= chaseRadius && state != State.following)
            {
                // follow state // following is moving to a spot right behind the player
            }
            if (health.HealthAsPercentage() <= .05 && state != State.fleeing)
            {
                // flee state
            }
        }
예제 #27
0
파일: EnemyAI.cs 프로젝트: emilizz1/RPG
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);

            if (isAlive)
            {
                bool inWeaponRange     = distanceToPlayer <= currentWeaponRange;
                bool inChaseRange      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
                bool outsideChaseRange = distanceToPlayer > chaseRadius;

                if (inChaseRange)
                {
                    StopAllCoroutines();
                    weaponSystem.StopAttacking();
                    StartCoroutine(ChasePlayer());
                    character.ReturnAnimationFowardCap();
                }
                else if (inWeaponRange)
                {
                    StopAllCoroutines();
                    state = State.attacking;
                    weaponSystem.AttackTarget(player.gameObject);
                }
                else if (outsideChaseRange && state != State.patrolling)
                {
                    StopAllCoroutines();
                    weaponSystem.StopAttacking();
                    StartCoroutine(Patrol());
                }
            }
            else
            {
                StopAllCoroutines();
            }
        }
예제 #28
0
파일: EnemyAI.cs 프로젝트: kadoohd/rpg-game
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            //bool playerIsOutOfRangeAndEnemyIsNotPatrolling = distanceToPlayer > chaseRadius && state != State.patrolling;

            bool inWeaponCircle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseCircle = distanceToPlayer > chaseRadius;

            if (outsideChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }

            //bool playerIsInRangeAndEnemyIsNotChasing = distanceToPlayer <= chaseRadius && state != State.chasing;
            if (inChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }

            //bool playerIsInWeaponRangeAndEnenyIsNotAttacking = distanceToPlayer <= currentWeaponRange && state != State.attacking;
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
예제 #29
0
        // Update is called once per frame
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().AttackRadius();
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);

            if (distanceToPlayer > aggroRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                StartCoroutine(Patrol());
            }
            if (distanceToPlayer <= aggroRadius && state != State.chasing)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }
            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                state = State.attacking;
                StopAllCoroutines();
                StartCoroutine(MoveAndAttack(player.gameObject));
            }
        }
예제 #30
0
 private void InitializeComponents()
 {
     player       = FindObjectOfType <PlayerControl>();
     character    = GetComponent <Character>();
     weaponSystem = GetComponent <WeaponSystem>();
 }