private Color hearingColor = Color.red;                     //Color for hearing sphere gizmo, init. red.



    // Start is called before the first frame update
    void Start()
    {
        //Get and set data and motor on Start
        data    = GetComponent <TankData>();
        motor   = GetComponent <TankMotor>();
        tf      = GetComponent <Transform>();
        shooter = GetComponent <TankShooter>();

        //get reference to manager player (temporary until next milestone)
        player = GameManager.instance.instantiatedPlayerTank;

        //Add self to GameManager list of enemies
        GameManager.instance.instantiatedEnemyTanks.Add(this.gameObject);

        //Get and Set Territory from randomly generated room, if not pre-set
        if (!territory)
        {
            //Set Territory to a random territory from the level game object - map generator list of territories
            territory = GameManager.instance.LevelGameObject.GetComponent <MapGenerator>().instantiatedTerritories[UnityEngine.Random.Range(0, GameManager.instance.LevelGameObject.GetComponent <MapGenerator>().instantiatedTerritories.Count)];
        }

        //Get and Set Waypoints array from territory, if waypoints array is null
        if (waypoints == null || waypoints.Length == 0)
        {
            waypoints = territory.waypoints;
        }

        //Teleport Swiss on start to middle of assigned territory (to avoid getting lost and stuck in generated map
        if (personality == Personalities.Swiss)
        {
            transform.position = territory.gameObject.transform.position;
        }
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     tf     = GetComponent <Transform>();
     data   = GetComponent <TankData>();
     motor  = GetComponent <TankMotor>();
     player = GameObject.FindWithTag("Player");
 }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     //tells when the game starts what these objects mean
     data    = gameObject.GetComponent <TankData>();
     motor   = gameObject.GetComponent <TankMotor>();
     shooter = gameObject.GetComponent <TankShooter>();
 }
Ejemplo n.º 4
0
    void Start()
    {
        data  = GetComponent <TankData>();
        motor = GetComponent <TankMotor>();

        GameManager.instance.players.Add(this.data);
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        // Access the TankMotor script
        motor = GetComponent <TankMotor>();
        // Access the TankData script
        data = GetComponent <TankData>();
        // Set originalSpeed equal to the designer set speed to allow changes in speed withough losing the original value
        originalSpeed     = data.moveSpeed;
        originalTurnSpeed = data.turnSpeed;

        // Access the Shoot script on the FirePoint object
        fire             = firePoint.GetComponent <Shoot>();
        fire.shellDamage = data.shellDamage;
        // Access the Game Manager script
        gmCaller = gmholder.GetComponent <GameManager>();
        //Access the MapGenerator script
        mapCaller = gmholder.GetComponent <MapGenerator>();

        avoidanceStage = 1;

        originalTime = avoidanceTime;

        mirroredFOV = 180 - FOV;

        state = "Patrol";

        timerReset = timer;

        fire.waitTime = data.fireRate;
    }
Ejemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     // Access the TankMotor script
     motor = GetComponent <TankMotor>();
     // Access the Shoot script on the FirePoint object
     fire = firePoint.GetComponent <Shoot>();
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     motor      = gameObject.GetComponent <TankMotor>();
     speedInfo  = gameObject.GetComponent <TankData>();
     ammunition = gameObject.GetComponent <TankData>().Ammo;
     noisemaker = gameObject.GetComponent <NoisemakerScript>();
 }
Ejemplo n.º 8
0
    public void SpawnTwoPlayer()
    {
        int        x            = Random.Range(0, map.rows);
        int        xx           = Random.Range(0, map.rows);
        int        z            = Random.Range(0, map.cols);
        int        zz           = Random.Range(0, map.cols);
        GameObject playerObjOne = Instantiate(playerPrefab, grid[x, z].gameObject.transform.FindChild("PlayerSpawn").position, Quaternion.identity) as GameObject;
        GameObject playerObjTwo = Instantiate(playerPrefab, grid[xx, zz].gameObject.transform.FindChild("PlayerSpawn").position, Quaternion.identity) as GameObject;

        player    = playerObjOne.GetComponent <TankMotor>();
        playerTwo = playerObjTwo.GetComponent <TankMotor>();

        Camera camOne = playerObjOne.GetComponentInChildren <Camera>();
        Camera camTwo = playerObjTwo.GetComponentInChildren <Camera>();

        camOne.rect = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
        camTwo.rect = new Rect(0.0f, 0.0f, 1.0f, 0.5f);

        playerObjTwo.GetComponent <InputController>().scheme = InputController.InputScheme.ArrowKeys;

        canvTwo.gameObject.SetActive(true);

        canvOne.GetComponent <Canvas>().worldCamera = camOne;
        canvTwo.GetComponent <Canvas>().worldCamera = camTwo;
    }
Ejemplo n.º 9
0
 private void Awake()
 {
     tf     = GetComponent <Transform>();
     motor  = GetComponent <TankMotor>();
     attack = GetComponent <TankShooter>();
     health = GetComponent <Health>();
 }
Ejemplo n.º 10
0
 public void RespawnPlayer()
 {
     if (PlayerPrefs.GetInt("TwoPlayers") == 1)
     {
         if (player.data.lives == player.data.prevLives - 1)
         {
             Debug.Log("spawning player 1");
             int        x            = Random.Range(0, map.rows);
             int        z            = Random.Range(0, map.cols);
             GameObject playerObjOne = Instantiate(playerPrefab, grid[x, z].gameObject.transform.FindChild("PlayerSpawn").position, Quaternion.identity) as GameObject;
             playerObjOne.GetComponent <TankData>().lives = player.data.lives;
             player = playerObjOne.GetComponent <TankMotor>();
             Camera camOne = playerObjOne.GetComponentInChildren <Camera>();
             camOne.rect = new Rect(0.0f, 0.5f, 1.0f, 0.5f);
             canvOne.GetComponent <Canvas>().worldCamera = camOne;
         }
         else if (playerTwo.data.lives == playerTwo.data.prevLives - 1)
         {
             Debug.Log("spawning player 2");
             int        x            = Random.Range(0, map.rows);
             int        z            = Random.Range(0, map.cols);
             GameObject playerObjTwo = Instantiate(playerPrefab, grid[x, z].gameObject.transform.FindChild("PlayerSpawn").position, Quaternion.identity) as GameObject;
             playerObjTwo.GetComponent <TankData>().lives = playerTwo.data.lives;
             playerTwo = playerObjTwo.GetComponent <TankMotor>();
             Camera camTwo = playerObjTwo.GetComponentInChildren <Camera>();
             camTwo.rect = new Rect(0.0f, 0.0f, 1.0f, 0.5f);
             playerObjTwo.GetComponent <InputController>().scheme = InputController.InputScheme.ArrowKeys;
             canvTwo.GetComponent <Canvas>().worldCamera          = camTwo;
         }
     }
     else
     {
         SpawnPlayer();
     }
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     //defines each variable at the start of the game
     data  = gameObject.GetComponent <TankData>();
     motor = gameObject.GetComponent <TankMotor>();
     tf    = gameObject.GetComponent <Transform>();
 }
Ejemplo n.º 12
0
    void OnDrawGizmos()
    {
        if (Application.isPlaying || Area == null || Area.Obs == null)
        {
            return;
        }
        if (Obs == null)
        {
            Motor         = GetComponent <TankMotor>();
            Motor.Trnsfrm = transform;
            Motor.Body    = GetComponent <Rigidbody2D>();
            init();
        }


        foreach (var o in Obs)
        {
            if (o.Ri >= Motor.Scanner.Count)
            {
                Obs = null;
                return;
            }
        }

        proc();
    }
 // Start is called before the first frame update
 void Start()
 {
     data    = gameObject.GetComponent <TankData>();
     motor   = gameObject.GetComponent <TankMotor>();
     tf      = gameObject.GetComponent <Transform>();
     shooter = gameObject.GetComponent <TankShooter>();
 }
 void Start()    // this doesn't get called for some reason?
 {
     motor  = gameObject.GetComponent <TankMotor>();
     data   = gameObject.GetComponent <TankData>();
     tf     = gameObject.GetComponent <Transform>();
     Target = GameObject.FindGameObjectWithTag("Player").transform;
 }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     shooter = GetComponent <TankShooter>();
     motor   = GetComponent <TankMotor>();
     data    = GetComponent <TankData>();
     health  = GetComponent <Health>();
 }
Ejemplo n.º 16
0
    void Start()
    {
        //
        //Get Scripts
        //

        if (data == null)
        {
            data = GetComponent <TankData>();
        }
        if (motor == null)
        {
            motor = GetComponent <TankMotor>();
        }
        if (gun == null)
        {
            gun = GetComponent <TankGun>();
        }

        //Add in spawn points
        waypoints = GameObject.FindGameObjectsWithTag("Spawn");
        //Get Transform Component
        tf = this.gameObject.GetComponent <Transform> ();
        //Get the currentWaypoint (Closest Waypoint);
        currentWaypoint          = GetClosestWayPoint(tf);
        looseCannonStartWayPoint = currentWaypoint;

        avoidanceStage = 0;

        sc        = GetComponent <SphereCollider> ();
        sc.radius = hearDistance;

        playerTf = GetComponent <Transform> ();
        playerTf = GameObject.FindGameObjectWithTag("Player").transform;
    }
Ejemplo n.º 17
0
    public float frontSensorAngle = 45f;                       //sets angle for secondary front sensor
    #endregion

    #endregion

    // Use this for initialization
    void Awake()
    {
        if (randomAttackState) //if designer chose to have a random attack state use this before anything else
        {
            rng = Random.Range(1, 51);
            if (rng <= 25) //if rng value is less than or equal to 25 select flee
            {
                SwitchTo = TypeofEnemy.Flee;
            }
            else //else if the value is higher choose to attack player
            {
                SwitchTo = TypeofEnemy.sawPlayer;
            }
        }
        motor_           = gameObject.GetComponent <TankMotor>();           //sets motor info from tankdata script
        tankInfo_        = gameObject.GetComponent <TankData>();            //sets speed info from tankdata script
        ammunition_      = gameObject.GetComponent <TankData>().Ammo;       //sets ammo type from tankdata script
        tankTransform_   = gameObject.GetComponent <Transform>();           //grabs transform of tank
        originalState_   = EnemyType;                                       //sets up an original state to default back to based off designer decision
        sensing          = GetComponent <AISensoryScript>();                //grabs sensory input from AISensoryScript
        originPoint      = gameObject.GetComponent <Transform>().position;  //sets up origin point based off tank spawn to go back to (if applicable)
        origlife         = gameObject.GetComponent <TankData>().tankHealth; // sets up life here to use
        origRespawnTime_ = respawnTime;                                     //sets original respawn time to user defined respawn time
        sfxAudio         = GetComponent <AudioSource>();
    }
Ejemplo n.º 18
0
 void Start()
 {
     if (data == null)
     {
         data = gameObject.GetComponent <TankData>();
     }
     if (motor == null)
     {
         motor = gameObject.GetComponent <TankMotor>();
     }
     target       = GameObject.FindGameObjectWithTag("Player").transform;//set initial target to player for personalities that require it
     nextFireTime = Time.time;
     //set default behaviors
     if (personality == Personality.AllTalk)
     {
         aiState = AIStates.ChaseAndFire;
     }
     else if (personality == Personality.Guard)
     {
         aiState = AIStates.Patrol;
     }
     else if (personality == Personality.PatrolAvoid)
     {
         aiState = AIStates.Patrol;
     }
     else if (personality == Personality.Flee)
     {
         aiState = AIStates.Flee;
     }
     //set hearing radius trigger size
     GetComponent <SphereCollider>().radius = hearingRadius;
 }
Ejemplo n.º 19
0
 //finds the needed scripts
 void Start()
 {
     motor  = GetComponent <TankMotor>();
     data   = GetComponent <TankData>();
     shoot  = GetComponent <Shoot>();
     health = GetComponent <Health>();
 }
Ejemplo n.º 20
0
    // Start is called before the first frame update
    void Start()
    {
        data = GetComponent <TankData>();

        motor = GetComponent <TankMotor>();

        shooter = GetComponent <TankShooter>();
    }
Ejemplo n.º 21
0
 // Start is called before the first frame update
 void Start()
 {
     data    = gameObject.GetComponent <TankData>();
     motor   = gameObject.GetComponent <TankMotor>();
     tf      = gameObject.GetComponent <Transform>();
     shooter = gameObject.GetComponent <TankShooter>();
     target  = GameManager.instance.instantiatedPlayerTank.transform;
 }
Ejemplo n.º 22
0
 public void add(TankMotor tm)
 {
     if (tm.GetComponent <AiTankController>())
     {
         return;
     }
     Tanks.Add(tm);
 }
Ejemplo n.º 23
0
 // Start is called before the first frame update
 void Start()
 {
     motor   = GetComponent <TankMotor>();
     data    = GetComponent <TankData>();
     shooter = GetComponent <TankShooter>();
     CanSee  = GetComponent <AISenses>();
     CanHear = GetComponent <AISenses>();
 }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     motor        = gameObject.GetComponent <TankMotor>();
     tankInfo_    = gameObject.GetComponent <TankData>();
     originalLife = gameObject.GetComponent <TankData>().tankHealth;
     ammunition   = gameObject.GetComponent <TankData>().Ammo;
     noisemaker   = gameObject.GetComponent <NoisemakerScript>();
     sfxAudio     = GetComponent <AudioSource>();
 }
    // Start is called before the first frame update
    void Start()
    {
        tf     = GetComponent <Transform>();
        data   = GetComponent <TankData>();
        motor  = GetComponent <TankMotor>();
        player = GameObject.FindWithTag("Player");

        GetComponent <AudioSource>().volume = .5f;
    }
Ejemplo n.º 26
0
 // Start is called before the first frame update
 void Start()
 {
     // Access the TankMotor script
     motor = GetComponent <TankMotor>();
     data  = GetComponent <TankData>();
     // Access the Shoot script on the FirePoint object
     fire          = firePoint.GetComponent <Shoot>();
     fire.waitTime = data.fireRate;
 }
Ejemplo n.º 27
0
 //gets scripts
 void Start()
 {
     data    = GetComponent <TankData>();
     motor   = GetComponent <TankMotor>();
     tf      = GetComponent <Transform>();
     shoot   = GetComponent <Shoot>();
     fov     = GetComponent <FOV>();
     hearing = GetComponent <Hearing>();
 }
Ejemplo n.º 28
0
 // Start is called before the first frame update
 void Start()
 {
     motor = gameObject.GetComponent <TankMotor>();
     data  = gameObject.GetComponent <TankData>();
     if (GameManager.Instance.playerOne == null)
     {
         GameManager.Instance.playerOne = this.gameObject;
     }
 }
Ejemplo n.º 29
0
    // Start is called before the first frame update
    void Start()
    {
        motor = gameObject.GetComponent <TankMotor>();

        // failsafe if forget to attach data
        if (data == null)
        {
            data = gameObject.GetComponent <TankData>();
        }
    }
Ejemplo n.º 30
0
    //TODO Set up a method. bool isNotAtFinalWaypoint = currentWaypoint < (waypoints.Length - 1);
    // Start is called before the first frame update
    void Start()
    {
        data    = GetComponent <TankData>();
        motor   = GetComponent <TankMotor>();
        shooter = GetComponent <TankShooter>();

        lastEventTime = Time.time - timerDelay;

        waypoints = GameObject.FindGameObjectsWithTag("patrolPoint");
    }