private void Awake()
 {
     //get the camera
     cam    = GlobalManager.GetGlobalManager().GetCamera();
     canvas = GlobalManager.GetGlobalManager().GetCanvas();
     //hp_bar_back.transform.SetParent(canvas.transform,false);
     //get the hp bar front and back
     //hp_bar_back = Instantiate(HpBar,Vector3.zero,Quaternion.identity,canvas.transform);
     //hp_bar_front = hp_bar_back.GetComponent<RawImage>();
 }
Ejemplo n.º 2
0
 private void Update()
 {
     remaining_time -= Time.deltaTime;
     if (can_spawn && remaining_time <= 0 && GlobalManager.GetGlobalManager().GetLevelManager().GetEnemys().Count < MaxEnemys)
     {
         //spawn the object
         Instantiate(SpawnObject, transform.position, Quaternion.identity);
         remaining_time = Delay;
     }
 }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Awake()
 {
     //init the enemy list
     enemys = new List <enemy_controller>();
     //init the player list
     player_units = new List <unit_control_script>();
     //init the spawner list
     spawners = new List <BasicSpawner>();
     GlobalManager.GetGlobalManager().SetLevelManager(this);
 }
Ejemplo n.º 4
0
 private void OnMouseDown()
 {
     //see if the player can respawn
     if (GlobalManager.GetGlobalManager().GetPlayerController().GetLives() > 0)
     {
         //respawn the player
         GlobalManager.GetGlobalManager().GetPlayerController().AddLives(-1);
         owner.Respawn();
         //destroy self
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Awake()
    {
        register_player_count = 0;
        //set up the registered player count

        //set up the is bot array
        is_bot = new bool[4];
        for (int i = 0; i < 4; i++)
        {
            is_bot[i] = false;
        }

        //add self to the global manager
        GlobalManager.GetGlobalManager().SetGameManager(this);
    }
    private void Start()
    {
        //set the hp to full
        hp = MaxHp;
        //create the hp bar
        hp_bar = Instantiate(HpBar);
        //create the bleed effect
        bleed_system = Instantiate(BleedEffect, transform.position + Vector3.up * HealthBarHeight, Quaternion.identity, transform).GetComponent <ParticleSystem>();
        bleed_system.Stop();
        //Get the player controller
        //player_controller = GameObject.Find("PlayerController").GetComponent<player_controller_script>();
        //get the camera
        cam           = GameObject.FindObjectOfType <Camera>();
        hp_controller = hp_bar.GetComponent <hp_bar_controller>();
        hp_controller.SetHpAndMaxHp(hp, MaxHp);
        //set default values
        can_attack      = CanAttack;
        can_be_attacked = _CanBeAttacked;
        can_move        = CanMove;
        can_cast        = CanCast;
        magic_immune    = MagicImmune;
        physical_immune = PhysicalImmune;
        can_die         = CanDie;
        //make sure the enemy is alive
        is_dead = false;

        //set the target to null
        target = null;

        GlobalManager.GetGlobalManager().GetLevelManager().AddEnemy(this);

        //get the nav agent
        if (can_attack)
        {
            nav_agent = GetComponent <NavMeshAgent>();
        }
    }
Ejemplo n.º 7
0
 void AddLifeBtnClicked()
 {
     //add a life tpo the player controller
     GlobalManager.GetGlobalManager().GetPlayerController().AddLives(1);
 }
Ejemplo n.º 8
0
 void ToggleSpawnersBtnClicked()
 {
     //toggle the spawners in the leveel manager
     GlobalManager.GetGlobalManager().GetLevelManager().ToggleSpawners();
 }
Ejemplo n.º 9
0
 public static game_manager GetGameManager()
 {
     return(GlobalManager.GetGlobalManager().GetGameManager());
 }
Ejemplo n.º 10
0
 public static level_manager GetLevelManager()
 {
     return(GlobalManager.GetGlobalManager().GetLevelManager());
 }
Ejemplo n.º 11
0
 private void OnDestroy()
 {
     //remove self from thje spawner list
     GlobalManager.GetGlobalManager().GetLevelManager().RemoveSpawner(this);
 }
Ejemplo n.º 12
0
 private void Start()
 {
     //add self to the level manager
     GlobalManager.GetGlobalManager().GetLevelManager().AddSpawner(this);
 }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        int reee;

        if (can_move == !CanMove)
        {
            reee = 3;
        }
        if (is_dead)
        {
            return;
        }
        if (hp < 0.0001)
        {
            hp = 0;
            gameObject.AddComponent <DieAndFall>().Duration = 2.0f;
            can_be_attacked = false;
            //destroy hp bar
            Destroy(hp_bar);
            Destroy(gameObject.GetComponent <NavMeshAgent>());
            Destroy(gameObject.GetComponent <CapsuleCollider>());
            Destroy(gameObject.GetComponent <NavMeshObstacle>());
            is_dead = true;
            return;
        }
        //set hp bar position
        //hp_bar_back.transform.position = cam.WorldToScreenPoint(transform.position);
        hp_controller.SetPosition(transform.position + Vector3.up * HealthBarHeight);
        //update the hp bars hp
        hp_controller.SetHpAndMaxHp(hp, MaxHp);

        //decide whether we can attack the player or noy
        //set attack target to something in range if we dont have one
        if (can_attack && heading_target == null && (target == null || target.IsDead()))
        {
            //get the units in range and choose one randomly
            List <unit_control_script> units_in_range = GlobalManager.GetGlobalManager().GetLevelManager().GetPlayerUnitsInRange(GetPosition(), DetectionRange);
            if (units_in_range.Count > 0)
            {
                heading_target = units_in_range[Random.Range(0, units_in_range.Count)];
            }
            else
            {
                heading_target = null;
            }
        }

        //Check to see if there are any units in attack range
        if (can_attack && (target == null || target.IsDead()))
        {
            List <unit_control_script> units_in_range = GlobalManager.GetGlobalManager().GetLevelManager().GetPlayerUnitsInRange(GetPosition(), AttackRange);
            if (units_in_range.Count > 0)
            {
                target = units_in_range[Random.Range(0, units_in_range.Count)];
            }
        }

        if (can_attack && target != null)
        {
            SetAttackOrder(target);
        }
        else if (can_attack && heading_target != null)
        {
            SetAttackOrder(heading_target);
        }

        ////get the nav agent
        //if (can_attack && nav_agent == null)
        //    nav_agent = GetComponent<NavMeshAgent>();
        //set the movespeed and acceleration
        if (can_move)
        {
            nav_agent.speed        = MoveSpeed / 10;
            nav_agent.angularSpeed = MoveSpeed;
            nav_agent.acceleration = MoveSpeed;
        }
        else
        {
            if (nav_agent != null)
            {
                nav_agent.speed        = 0;
                nav_agent.acceleration = 0;
            }
        }

        //check to see if we can attack the player
        if (can_attack && (target != null || !target.IsDead()) && Vector3.Distance(target.transform.position, transform.position) < AttackRange / 100.0f)
        {
            windup -= Time.deltaTime;
        }
        else
        {
            //reset windup
            windup = BaseAttackTime;
        }

        if (can_attack && windup <= 0)
        {
            //attack the enemy target
            target.Damage(Damage, this);
            //reset windup
            windup = BaseAttackTime;
        }
    }