void Start()
    {
        radiusSqr = radius * radius;
        zombie = GetComponent<ZombieController> ();

        StartCoroutine (UpdateFollowTargetCoroutine());
    }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     chargeTimer = 15;
     chargeTime = 5;
     spawnTimer = 8;
     spawnTime = 3;
     zc = GetComponent<ZombieController>();
     zc.speed = 4;
     zc.health = 25+25*bossLevel;
     zc.deathDelay = 1;
 }
Exemplo n.º 3
0
    void ClearDeadZombie(NDictionary args = null)
    {
        List <int> record = new List <int>();

        for (int i = 0; i < zombieList.Count; i++)
        {
            ZombieController zombie = zombieList[i];
            if (zombie == null || zombie.gameObject.tag != "Zombie")
            {
                record.Add(i);
            }
        }
        for (int i = record.Count - 1; i >= 0; i--)
        {
            zombieList.RemoveAt(i);
        }
    }
Exemplo n.º 4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         DeathScript deathscript = other.gameObject.GetComponent <DeathScript>() as DeathScript;
         deathscript.ResetPlayer();
     }
     else if (other.gameObject.tag == "zombie")
     {
         ZombieController zombiScript = other.gameObject.GetComponent <ZombieController>() as ZombieController;
         zombiScript.KillZombie();
     }
     else if (other.gameObject.tag == "ball")
     {
         BallOfForce ball = other.gameObject.GetComponent <BallOfForce>() as BallOfForce;
         ball.DestroyBall();
     }
 }
Exemplo n.º 5
0
    private void Shoot()
    {
        //LayerMask finalMask = ~(LayerMask.GetMask("MeleeEnemy") | LayerMask.GetMask("SavingPoint") | LayerMask.GetMask(""));
        LayerMask  finalMask = ~(LayerMask.GetMask("MeleeEnemy") | LayerMask.GetMask("SavingPoint"));
        RaycastHit hit;
        Vector3    startpos = shootPoint.transform.position;

        if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.TransformDirection(Vector3.forward), out hit, 300f, finalMask))
        {
            GameObject hitted = hit.collider.gameObject;
            aimingForHit = true;
            hitPoint     = hit.point;
            enemyHit     = false;
            if (hitted.tag == "Enemy")
            {
                enemyHit = true;
                ZombieController zombie = hitted.transform.root.GetComponent <ZombieController>();
                zombie.TakeDamage(Random.Range(5f, 10f));
            }
            if (hitted.tag == "EnemyHead")
            {
                enemyHit = true;
                ZombieController zombie = hitted.transform.root.GetComponent <ZombieController>();
                zombie.TakeDamage(Random.Range(25f, 50f));
            }
        }
        else
        {
            aimingForHit = false;
            enemyHit     = false;
            nonHitPoint  = mainCamera.transform.position + mainCamera.transform.TransformDirection(Vector3.forward) * 100f;
        }
        StartCoroutine("ShakeCam");
        StartCoroutine("CrossScale");
        animator.Play("AimingLayer.shoot", 1, 0);
        animator.SetBool("shoot", true);
        shootingAudioSource.clip = shootSounds[Random.Range(0, shootSounds.Length)];
        shootingAudioSource.Play();
        Instantiate(muzzlePrefab, shootPoint.transform.position, shootPoint.transform.rotation, shootPoint.transform.parent);
        Instantiate(bulletPrefab, startpos, Quaternion.identity);
        shot++;
        timer = 0f;
    }
Exemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            anim.SetTrigger("attack");

            RaycastHit hit;

            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                Debug.Log(hit.transform.name);
                ZombieController zCtrl = hit.transform.GetComponentInParent <ZombieController>();
                if (zCtrl != null)
                {
                    zCtrl.TakeDamage(damage);
                }
            }
        }
    }
Exemplo n.º 7
0
    private void OnTriggerEnter(Collider CollisionObject)
    {
        Quaternion oppositeRotationBullet = Quaternion.LookRotation(transform.forward);

        switch (CollisionObject.tag)
        {
        case "Inimigo":
            ZombieController player = CollisionObject.GetComponent <ZombieController>();
            player.ZombieBloodMethod(transform.position, oppositeRotationBullet);
            player.GetDamage(shotDamage);
            break;

        case "Boss":
            BossController boss = CollisionObject.GetComponent <BossController>();
            boss.BossBloodMethod(transform.position, oppositeRotationBullet);
            boss.GetDamage(shotDamage);
            break;
        }
        Destroy(gameObject);
    }
Exemplo n.º 8
0
    /// <summary>
    /// 溅射 不包含普工
    /// </summary>
    /// <param name="zc"></param>
    void Splash(ZombieController zc)
    {
        var enemy       = zc.target.GetComponent <ZombieController>();
        var enemySecond = zc.player._ZombieMgr.GetNearZombie(enemy, enemy.player, 1);
        var enemyThird  = zc.player._ZombieMgr.GetNearZombie(enemySecond, enemySecond.player, 1);

        while (enemy == enemyThird)
        {
            enemyThird = zc.player._ZombieMgr.GetNearZombie(enemySecond, enemySecond.player, 1);
        }

        var go = BulletMgr.Instance.CreateBullet(eBulletType.SkillSplashBullet).GetComponent <SkillSplashBullet>();

        go.Init(zc.transform, enemySecond.transform);
        go.myZc       = zc;
        go.enemy1     = enemySecond;
        go.enemy2     = enemyThird;
        go.sb         = go;
        go.splashExit = SecondSplash;
    }
Exemplo n.º 9
0
    private void VerifyIfHits()
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenToWorldPoint(crossHair.transform.position), player.fpsCamera.transform.forward * 1000, out hit))
        {
            if (hit.collider.CompareTag("Head"))
            {
                Instantiate(explosion, hit.point, Quaternion.identity);
                ZombieController zombie = hit.collider.GetComponentInParent <ZombieController>();
                zombie.Desitegrate();
            }
            else if (hit.collider.CompareTag("Body"))
            {
                Instantiate(blood, hit.point, Quaternion.identity);
                ZombieController zombie = hit.collider.GetComponentInParent <ZombieController>();
                zombie.TakeDamage(damage);
            }
        }
    }
Exemplo n.º 10
0
    void TestZombieCollision(GameObject other, ParticleCollisionEvent collision)
    {
        if (other.name.Contains("ZombieLowQuality"))
        {
            ZombieController zombie   = other.GetComponent <ZombieController>();
            ZombieCollider   collider = zombie.GetZombieCollider(collision.colliderComponent.name);
            zombie.UpdateHealth(collider);

            if (zombie.GetHealth() <= 0)
            {
                Statics.ScoreController.Score += zombie.EnemyDeathScore(collider);
                objectPooler.ReleaseToPool(other, "Zombie");
                enemyGenerator.numberOfZombies--;
            }
            else
            {
                Statics.ScoreController.Score += zombie.CollisionScore(collider);
            }
        }
    }
Exemplo n.º 11
0
 private void PrecreateObjects()
 {
     zombiePool = new Queue <ZombieController>();
     for (int i = 0; i < GameLogic.ZOMBIE_AMOUNT; i++)
     {
         GameObject       go     = GameObject.Instantiate(zombiePrefab) as GameObject;
         ZombieController zombie = go.GetComponent <ZombieController>();
         zombie.gameLogic = gameLogic;
         zombie.SetManager(this);
         zombie.player = player;
         if (zombie == null)
         {
             Debug.LogError("Cannot fint the component Zombie in the zombie prefab.");
         }
         go.name             = zombiePrefab.name;
         go.transform.parent = transform;
         go.SetActive(false);
         zombiePool.Enqueue(zombie);
     }
 }
Exemplo n.º 12
0
    private void UpdateTarget()
    {
        var zombiesInRange = FindObjectsOfType <ZombieController>().Where(x => Vector2.Distance(x.transform.position, transform.position) < attackRange).
                             OrderBy(x => Vector2.Distance(x.transform.position, transform.position));

        targetZombie = null;
        foreach (var zombie in zombiesInRange)
        {
            if (!attackOverWalls && !HasLOS(zombie.transform.position))
            {
                continue;
            }
            float distance = Vector2.Distance(transform.position, zombie.transform.position);
            if (distance <= attackRange)
            {
                targetZombie = zombie;
                return;
            }
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// 当前卡牌伤害数据缓存
    /// </summary>
    public void TriggerActiveSkill(ZombieController zc)
    {
        if (r.Next(0, 100) <= skillData.probability)
        {
            switch (zc.zombie.skill)
            {
            case eSkillType.Splash:
                Splash(zc);
                break;

            case eSkillType.TauntAll:
                TauntAll(zc);
                break;

            case eSkillType.ZombieWave:
                ZombieWave(zc);
                break;
            }
            isOK = false;
        }
    }
Exemplo n.º 14
0
    void Start()
    {
        if (slowZombieRef.GetComponent <ZombieController>())
        {
            zombieController = slowZombieRef.GetComponent <ZombieController>();
            droneController  = null;
            zombIsHere       = true;
        }
        else if (slowZombieRef.GetComponent <DroneController>())
        {
            droneController = slowZombieRef.GetComponent <DroneController>();


            zombieController = null;
            droneIsHere      = true;
        }

        setKinematic(true);
        player = GameObject.FindGameObjectWithTag("gm");
        gm     = player.GetComponent <GameManager>();
    }
Exemplo n.º 15
0
    void CmdspawnZombies()
    {
        if (waitingForWave)
        {
            if (newWaveTimer >= 0)
            {
                newWaveTimer -= Time.deltaTime;
            }
            else
            {
                //Initialize new wave
                enemiesToEliminate  = waveNumber * enemiesPerWave;
                enemiesEliminated   = 0;
                totalEnemiesSpawned = 0;
                waitingForWave      = false;
            }
        }
        else
        {
            if (Time.time > nextSpawnTime)
            {
                nextSpawnTime = Time.time + spawnInterval;

                //Spawn enemy
                if (totalEnemiesSpawned < enemiesToEliminate)
                {
                    if (isServer)
                    {
                        Transform  randomPoint = spawnPoints[Random.Range(0, spawnPoints.Length - 1)];
                        GameObject enemy       = Instantiate(enemyPrefab[Random.Range(0, enemyPrefab.Length)], randomPoint.position, Quaternion.identity);
                        NetworkServer.Spawn(enemy, connectionToClient);
                        ZombieController npc = enemy.GetComponent <ZombieController>();
                        npc.playerTransform = player.transform;
                        npc.es = this;
                        totalEnemiesSpawned++;
                    }
                }
            }
        }
    }
Exemplo n.º 16
0
    private void Fire()
    {
        if (m_inputHandler.GetLeftMousePressed() && equipped != 0)
        {
            if (m_canFire)
            {
                equippedGun.MuzzleFlash.Play();

                Ray        ray = m_camera.ViewportPointToRay(m_centreOfScreen);
                RaycastHit hit;
                Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);

                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.transform.gameObject.tag == "Monster")
                    {
                        m_playerStats.Money += 10;

                        var rotation = Vector3.up * 180.0f;

                        bloodSplatterObject.transform.position = hit.transform.position;
                        bloodSplatterObject.transform.Rotate(rotation, Space.World);
                        bloodSplatterEffect.Play();

                        ZombieController zombieController = hit.transform.gameObject.GetComponent <ZombieController>();

                        zombieController.Health    -= equippedGun.Base_damage;
                        zombieController.LastPlayer = m_playerStats;
                    }
                }

                m_rotationHelper.transform.Rotate(new Vector3(equippedGun.YKickBase, 0, 0), Space.Self); //Vertical recoil.
                transform.Rotate(new Vector3(0, equippedGun.XKickBase, 0), Space.Self);                  //Horizontal recoil.

                m_bulletsLeftInClip--;                                                                   //Reduce number of bullets remaining.

                StartCoroutine(WaitForShot());                                                           //Delay next shot.
            }
        }
    }
Exemplo n.º 17
0
    void OnTriggerEnter(Collider other)
    {
        //Zombie has entered the freeze zone
        if (other.gameObject.CompareTag("BasicZombie"))
        {
            ZombieController zc = other.gameObject.GetComponent <ZombieController> ();

            //The zombie is currently moving
            if (zc.CanMove())
            {
                //Make it stop
                zc.TriggerCanMove();
                //Add this zombie to this skills list of frozen zombies
                frozenZombies.Add(zc);
                SlideToSurviveAchievements.archerAchievement.ZombieFrozen();

                //make frozen zombie tomb in that spot
                GameObject frozenTomb = (GameObject)Instantiate(frozenZombieTombPrefab, other.gameObject.transform.position, Quaternion.identity);
                frozenZombieTombs.Add(frozenTomb);
            }
        }
    }
Exemplo n.º 18
0
    private void EnemyDelay()        // The enemy is spawned 1 second after the particle effect apears.
    {
        random = Random.Range(1, 6); // chooses a random enemy
        if (random <= 2)             // chooses the enemy to spawn
        {
            ZombieController newEnemy = Instantiate(zombie, transform.position, Quaternion.identity) as ZombieController;
        }
        else if (random == 3)
        {
            ShooterControler newEnemy = Instantiate(shooter, transform.position, Quaternion.identity) as ShooterControler;
        }
        else if (random == 4)
        {
            runnerController newEnemy = Instantiate(runner, transform.position, Quaternion.identity) as runnerController;
        }
        else if (random == 5)
        {
            shotgunnerController newEnemy = Instantiate(shotgunner, transform.position, Quaternion.identity) as shotgunnerController;
        }

        Destroy(gameObject); // deletes the particle effect
    }
Exemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        a_time += Time.deltaTime;
        if (Time.time - u_time > updateTime)
        {
            GameObject[] zombies = GameObject.FindGameObjectsWithTag("zombie");
            if (zombies.Length > 0)
            {
                u_time = Time.time;
                print("Update Zombie");
                serialPort.UpdateZombie();
            }
        }

        if (Time.time - time > spawnTime)
        {
            time = Time.time;
            GameObject       obj = Instantiate(zombies, new Vector3(3, 0, 27f), Quaternion.identity) as GameObject;
            ZombieController zc  = obj.GetComponent <ZombieController>();
            //zc.queue = queue;
            zc.SetID(zombieCount);
            zc.SetSerialPort(serialPort);
            obj.transform.localScale = new Vector3(35.0f, 35.0f, 35.0f);
            obj.tag = "zombie";
            //queue.Enqueue(obj);
            print("Spawn Zombie" + zombieCount);
            zombieCount++;
            serialPort.SpawnZombie(zombieCount);
        }
        if (Input.GetMouseButtonDown(0))
        {
            BuildBlock(0, 0);
        }
        if (Input.GetMouseButtonDown(1))
        {
            ShootArrow();
        }
    }
Exemplo n.º 20
0
    void Shoot()
    {
        RaycastHit _hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, range, mask))
        {
            //debugger, we hit something
            Debug.Log("hit " + _hit.collider.name);
            ZombieController target = _hit.transform.GetComponent <ZombieController>();
            if (target != null)
            {
                if (target.currentHealth - damage <= 0)
                {
                    player.UpdatePoints(50);
                }
                else
                {
                    player.UpdatePoints(10);
                }
                target.TakeDamage(damage);
            }
        }
    }
Exemplo n.º 21
0
    public void SpawnMoreZombies(float chance)
    {
        if (moveSpeed == 0 || !canSpawnMoreZombies) // Dummies can't spawn more.
        {
            return;
        }

        if (Random.Range(0f, 1f) < chance)
        {
            ZombieController newZombie = GameObject.Instantiate(this).GetComponent <ZombieController>();

            newZombie.canSpawnMoreZombies = false;
            newZombie.transform.position  = transform.position;
            newZombie.velocity            = player.transform.position - transform.position * 0.3f;
            newZombie.name = "Zombie Minion";


            newZombie.Start();
            newZombie.Update();
        }

        canSpawnMoreZombies = false;
    }
Exemplo n.º 22
0
    /// <summary>
    /// Why am I writing these, I need sleep
    /// </summary>
    /// <param name="pos"></param>
    /// <param name="radius"></param>
    /// <param name="damage"></param>
    /// <param name="id"></param>
    public static void DealDamageInRadius(Vector3 pos, float radius, int damage, UnityEngine.Networking.NetworkInstanceId id)
    {
        Collider[] hitColliders = Physics.OverlapSphere(pos, radius);

        List <HealthController> targets = new List <HealthController>();

        foreach (Collider col in hitColliders)
        {
            if (col.transform.root.GetComponent <ZombieController>())
            {
                ZombieController zc = col.transform.root.GetComponent <ZombieController>();

                if (!targets.Contains(zc))
                {
                    targets.Add(zc);
                }
            }

            if (col.transform.root.GetComponent <WallController>())
            {
                WallController wc = col.transform.root.GetComponent <WallController>();

                if (!targets.Contains(wc))
                {
                    targets.Add(wc);
                }
            }
        }

        if (targets.Count > 0)
        {
            foreach (HealthController z in targets.ToArray())
            {
                z.TakeDamage(damage, id);
            }
        }
    }
    public void OnTriggerEnter(Collider col)
    {
        SkeletonController skelController = col.GetComponent <SkeletonController>();

        if (skelController != null)
        {
            skelController.CurrentHealth -= playerController.Attack / 5;
        }

        ZombieController zombController = col.GetComponent <ZombieController>();

        if (zombController != null)
        {
            zombController.CurrentHealth -= playerController.Attack / 5;
        }

        MonsterControllerV2 monstController = col.GetComponent <MonsterControllerV2>();

        if (monstController != null)
        {
            monstController.CurrentHealth -= playerController.Attack / 5;
        }

        GolemControllerV2 golemController = col.GetComponent <GolemControllerV2>();

        if (golemController != null)
        {
            golemController.CurrentHealth -= playerController.Attack / 6;
        }

        BossController bossController = col.GetComponent <BossController>();

        if (bossController != null)
        {
            bossController.health -= playerController.Attack / 15;
        }
    }
Exemplo n.º 24
0
 private void CheckIfAttacking()
 {
     RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, spriteRenderer.flipX ? Vector2.left : Vector2.right, 1.0f);
     foreach (RaycastHit2D hit in hits)
     {
         if (hit.collider != null)
         {
             if (hit.collider.tag == "Zombie")
             {
                 ZombieController zombie = hit.collider.GetComponent <ZombieController>();
                 if (zombie != null)
                 {
                     if (zombie.StartHit())
                     {
                         audioSource.clip   = attackClip;
                         audioSource.volume = 0.3f;
                         audioSource.Play();
                     }
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 25
0
    void SpawnZombies()
    {
        Vector3 vanPos = vehicle.transform.position;


        for (int i = 0; i < ZombiesSpawned; i++)
        {
            float x = Random.Range(-10.0f, 10.0f);
            float y = Random.Range(-5.0f, 5.0f);

            Vector3 spawnPos = vanPos - new Vector3(0 + x, 10 + y, 0);

            //int g = Random.Range(1, 10);
            int g = 7;
            if (g == 7)
            {
                float   xx        = Random.Range(-10.0f, 10.0f);
                float   yy        = Random.Range(-5.0f, 5.0f);
                Vector3 spawnPos2 = vanPos - new Vector3(0 + xx, 10 + yy, 0);
                //spawnPos2 = new Vector3(0, -2, 0);

                VaperControlScript vaper = (VaperControlScript)Instantiate(vaperControlScript, spawnPos2, Quaternion.identity);
                vaper.gameObject.name  = "Vaper" + i;
                vaper.transform.parent = Gnmies.transform;

                FreddyHuggerController ff = (FreddyHuggerController)Instantiate(FFController, spawnPos2, Quaternion.identity);
                ff.gameObject.name  = "FreddyFucker" + i;
                ff.transform.parent = Gnmies.transform;
            }
            ZombieController zombie = (ZombieController)Instantiate(zombieController, spawnPos, Quaternion.identity);
            zombie.gameObject.name  = "Zombie" + i;
            zombie.transform.parent = Gnmies.transform;
            //print(spawnPos + " " + i);
            print(zombie.transform.position + " " + i);
        }
    }
Exemplo n.º 26
0
    private void OnZombieDied(ZombieController controller, Zombie zombie)
    {
        if (zombie.IsBoss)
        {
            _lastBossAlive = false;
        }

        if (_zombies.Contains(zombie))
        {
            _zombies.Remove(zombie);
            _zombiePool.ReturnZombieModel(zombie);
        }

        int nextWave = WaveNumber + 1;

        if (nextWave == _gameConfig.waveSettings.firstBossWaveNumber && _tutorialManager.IsTutorialEnabled)
        {
            if (_zombies.Count == 0)
            {
                _waveStarted      = false;
                _autoStartNewWave = false;
                _tutorialManager.StartHandDDTutorial();
            }

            SetDirty();
            return;
        }

        if (_tutorialManager.IsTutorialWave)
        {
            if (_zombies.Count == 0)
            {
                _waveStarted = false;
                _tutorialManager.CompleteTutorialStep(_tutorialManager.ActiveTutorialStep.Action);
            }

            SetDirty();
            return;
        }

        _onUpdateZombiesCountSignal.Fire(_zombies.Count);
        if (_nightManager.IsNightActive)
        {
            if (_zombies.Count == 0)
            {
                _windowsManager.ShowWindow <NightEndWindow>();
            }

            return;
        }

        if (!_autoStartNewWave)
        {
            return;
        }

        if (_zombies.Count <= _gameConfig.waveSettings.zombiesToStartNewWave)
        {
            StartNewWave();
        }

        SetDirty();
    }
Exemplo n.º 27
0
 // Start is called before the first frame update
 void Start()
 {
     thisZombieController = transform.parent.GetComponent <ZombieController>();
 }
Exemplo n.º 28
0
    public void DoAction()
    {
        ZombieController player = isThereNearbyPlayer();

        if (player == null)
        {         // Attack if there's a player nearby, move if not
            int random = Random.Range(0, 3);
            switch (random)
            {
            case 0: {
                bool canMove = true;
                foreach (Entity e in TileManager.getInstance().getTile(getX() + 1, getY()).getEntities())
                {
                    if (e.getIdentity() == "Enemy")
                    {
                        canMove = false;
                    }
                }
                if (canMove)
                {
                    MoveRight();
                }
                break;
            }

            case 1: {
                bool canMove = true;
                foreach (Entity e in TileManager.getInstance().getTile(getX() - 1, getY()).getEntities())
                {
                    if (e.getIdentity() == "Enemy")
                    {
                        canMove = false;
                    }
                }
                if (canMove)
                {
                    MoveLeft();
                }
                break;
            }

            case 2: {
                bool canMove = true;
                foreach (Entity e in TileManager.getInstance().getTile(getX(), getY() + 1).getEntities())
                {
                    if (e.getIdentity() == "Enemy")
                    {
                        canMove = false;
                    }
                }
                if (canMove)
                {
                    MoveForward();
                }
                break;
            }

            case 3: {
                bool canMove = true;
                foreach (Entity e in TileManager.getInstance().getTile(getX(), getY() - 1).getEntities())
                {
                    if (e.getIdentity() == "Enemy")
                    {
                        MoveBackward();
                    }
                }
                if (canMove)
                {
                    MoveBackward();
                }
                break;
            }
            }
        }
        else         // ATTACK THE PLAYER
        {
            attackCount = 10;
            Attack(player);
            player = null;
        }
        //lastResort++;
    }
 private void Start()
 {
     parent = GetComponentInParent <ZombieController>();
 }
 public void BeforeTest()
 {
     zombieMovementController = GetZombieMovementMock();
     controller = new ZombieController();
     controller.SetMovementController(zombieMovementController);
 }
 // Use this for initialization
 void Start()
 {
     zombie = GetComponent<ZombieController> ();
 }
Exemplo n.º 32
0
 public static void OnZombieHurt(Controller controller, ZombieController zombieController, DamageEvent damage)
 {
     if (!zombieController.HasTarget())
     {
         Character newTarg = damage.attacker.character;
         if (newTarg != null)
         {
             if (newTarg != zombieController.attackTarget)
             {
                 zombieController.SetTarget(newTarg);
                 zombieController.lastAttackedMePosition = newTarg.origin;
             }
             zombieController.targetAttackedMe = true;
             if (zombieController.wasRoaming)
             {
                 zombieController.RoamFrameEnd();
                 NavMeshAgent agent = controller.agent;
                 if (agent != null)
                 {
                     if (!beingDestroyed.Contains(damage.victim.idMain.gameObject))
                         agent.ResetPath();
                     else
                         beingDestroyed.Remove(damage.victim.idMain.gameObject);
                 }
                 zombieController.wasRoaming = false;
                 zombieController.currentlyRoaming = false;
             }
         }
     }
 }
Exemplo n.º 33
0
    void SavePlayerData()
    {
        //Player position and madness
        currentGameData.playerMadness = PlayerController.playerControllerInstance.madness;
        currentGameData.playerPosX    = PlayerController.playerControllerInstance.transform.position.x;
        currentGameData.playerPosY    = PlayerController.playerControllerInstance.transform.position.y;
        currentGameData.playerPosZ    = PlayerController.playerControllerInstance.transform.position.z;

        //Urbanization objects
        currentGameData.foodTaken      = PlayerController.playerControllerInstance.foodTaken;
        currentGameData.diaryPageTaken = PlayerController.playerControllerInstance.diaryPageTaken;

        //Player flags
        currentGameData.makeUpTaken = PlayerController.playerControllerInstance.isMadeUp;
        currentGameData.ladderTaken = PlayerController.playerControllerInstance.hasLadder;
        currentGameData.wineTaken   = PlayerController.playerControllerInstance.hasWine;
        currentGameData.luculoTaken = PlayerController.playerControllerInstance.hasCat;

        //NPCs condition
        currentGameData.npcInteracted[0] = GameObject.Find("Carlos").GetComponent <InteractPerson>().alreadyInteracted;
        currentGameData.npcInteracted[1] = GameObject.Find("SeñoraRamos").GetComponent <InteractPerson>().alreadyInteracted;
        currentGameData.npcInteracted[2] = GameObject.Find("Jaime").GetComponent <InteractPerson>().alreadyInteracted;
        currentGameData.npcInteracted[3] = GameObject.Find("Paco").GetComponent <InteractPerson>().alreadyInteracted;

        //Inventory
        currentGameData.itemList = new List <Item>(Inventory.inventoryInstance.itemList);

        //Arrows
        currentGameData.arrowList.Clear();
        quiver = GameObject.Find(Names.quiverObject).transform;
        string parent;

        foreach (GameObject arrow in GameObject.FindGameObjectsWithTag("Arrow"))
        {
            if (arrow.transform.parent == null)
            {
                parent = null;
            }
            else
            {
                parent = arrow.transform.parent.name;
            }
            currentGameData.arrowList.Add(new ArrowData(new float[3] {
                arrow.transform.position.x, arrow.transform.position.y, arrow.transform.position.z
            }, parent, arrow.activeSelf, arrow.GetComponent <Rigidbody>().isKinematic));
        }
        foreach (Transform arrow in quiver)
        {
            currentGameData.arrowList.Add(new ArrowData(new float[3] {
                arrow.position.x, arrow.position.y, arrow.transform.position.z
            }, arrow.parent.name, arrow.gameObject.activeSelf, arrow.GetComponent <Rigidbody>().isKinematic));
        }

        //Zombies condition
        currentGameData.zombieList.Clear();
        horde = GameObject.Find("Zombies").transform;
        foreach (Transform zombie in horde)
        {
            ZombieController zc = zombie.gameObject.GetComponent <ZombieController>();
            currentGameData.zombieList.Add(new ZombieData(new float[3] {
                zombie.position.x, zombie.position.y, zombie.transform.position.z
            }, zc.life, zombie.gameObject.activeSelf, zc.firstAttackFlag));
        }

        //Difficulty settings
        currentGameData.timeDamage   = PlayerController.playerControllerInstance.timeDamage;
        currentGameData.timeIncrease = PlayerController.playerControllerInstance.timeIncrease;

        //currentGameData.SceneID = SceneManager.GetActiveScene().buildIndex;
    }
Exemplo n.º 34
0
	ZombieController zombie; // ZombieController of this zombie

	void Awake () {
		zombie = GetComponent<ZombieController> ();
	}
Exemplo n.º 35
0
    public void LoadPlayerData()
    {
        int i = 0;

        //SceneManager.LoadScene(currentGameData.SceneID+1);

        //Player position and madness
        PlayerController.playerControllerInstance.madness            = currentGameData.playerMadness;
        PlayerController.playerControllerInstance.transform.position = new Vector3(currentGameData.playerPosX, currentGameData.playerPosY, currentGameData.playerPosZ);

        //Urbanization objects
        i = 0;
        GameObject.Find("Tupper0").SetActive(!currentGameData.foodTaken[0]);
        GameObject.Find("Tupper1").SetActive(!currentGameData.foodTaken[1]);
        GameObject.Find("Tupper2").SetActive(!currentGameData.foodTaken[2]);
        GameObject.Find("Tupper3").SetActive(!currentGameData.foodTaken[3]);
        GameObject.Find("Tupper4").SetActive(!currentGameData.foodTaken[4]);
        GameObject.Find("Tupper5").SetActive(!currentGameData.foodTaken[5]);
        GameObject.Find("DiaryPage1").SetActive(!currentGameData.diaryPageTaken[0]);
        GameObject.Find("DiaryPage2").SetActive(!currentGameData.diaryPageTaken[1]);
        GameObject.Find("DiaryPage3").SetActive(!currentGameData.diaryPageTaken[2]);
        GameObject.Find("DiaryPage4").SetActive(!currentGameData.diaryPageTaken[3]);

        GameObject.Find(Names.makeup).SetActive(!currentGameData.makeUpTaken);
        GameObject.Find(Names.wine).SetActive(!currentGameData.ladderTaken);
        GameObject.Find(Names.ladder).SetActive(!currentGameData.wineTaken);
        GameObject.Find(Names.cat).SetActive(!currentGameData.luculoTaken);

        //Player flags
        PlayerController.playerControllerInstance.isMadeUp  = currentGameData.makeUpTaken;
        PlayerController.playerControllerInstance.hasLadder = currentGameData.ladderTaken;
        PlayerController.playerControllerInstance.hasWine   = currentGameData.wineTaken;
        PlayerController.playerControllerInstance.hasCat    = currentGameData.luculoTaken;
        PlayerController.playerControllerInstance.hasFood   = currentGameData.foodTaken[0];

        //NPCs condition
        GameObject.Find("Carlos").GetComponent <InteractPerson>().alreadyInteracted      = currentGameData.npcInteracted[0];
        GameObject.Find("SeñoraRamos").GetComponent <InteractPerson>().alreadyInteracted = currentGameData.npcInteracted[1];
        GameObject.Find("Jaime").GetComponent <InteractPerson>().alreadyInteracted       = currentGameData.npcInteracted[2];
        GameObject.Find("Paco").GetComponent <InteractPerson>().alreadyInteracted        = currentGameData.npcInteracted[3];

        //Inventory
        Inventory.inventoryInstance.itemList = new List <Item>(currentGameData.itemList);
        Inventory.inventoryInstance.UpdateSlots();

        //Arrows
        quiver = GameObject.Find(Names.quiverObject).transform;
        i      = 0;
        foreach (Transform arrow in quiver)
        {
            if (currentGameData.arrowList[i].parentName == null)
            {
                arrow.parent = null;
            }
            else
            {
                arrow.parent = GameObject.Find(currentGameData.arrowList[i].parentName).transform;
            }
            arrow.position = currentGameData.arrowList[i].getPos();
            arrow.gameObject.SetActive(currentGameData.arrowList[i].isActive);
            arrow.GetComponent <Rigidbody>().isKinematic = currentGameData.arrowList[i].isKinematic;
            i++;
        }

        //Zombies condition
        horde = GameObject.Find("Zombies").transform;
        i     = 0;
        foreach (Transform zombie in horde)
        {
            ZombieController zc = zombie.gameObject.GetComponent <ZombieController>();
            currentGameData.zombieList.Add(new ZombieData(new float[3] {
                zombie.position.x, zombie.position.y, zombie.transform.position.z
            }, zc.life, zombie.gameObject.activeSelf, zc.firstAttackFlag));
            zombie.position = currentGameData.zombieList[i].getPos();
            zc.life         = currentGameData.zombieList[i].life;
            zombie.gameObject.SetActive(currentGameData.zombieList[i].isActive);
            zc.firstAttackFlag = currentGameData.zombieList[i].firstAttackFlag;
            i++;
        }

        //Difficulty settings
        PlayerController.playerControllerInstance.timeDamage   = currentGameData.timeDamage;
        PlayerController.playerControllerInstance.timeIncrease = currentGameData.timeIncrease;
    }
Exemplo n.º 36
0
    public override ActionResult Start(Agent agent, float deltaTime)
    {
        controller = agent.Avatar.GetComponentInChildren<ZombieController>();

        return ActionResult.SUCCESS;
    }