Example #1
0
    public void Die()
    {
        if (isLocalPlayer)
        {
            PlayerCanvas.canvas.WriteGameStatusText("Respawn in " + respawnTime + " seconds");
            PlayerCanvas.canvas.PlayDeathAudio();
        }


        DisablePlayer();
        Debug.Log("There are " + AIToNotifyWhenYouDie.Count + " to notify of death.");
        for (int i = 0; i < AIToNotifyWhenYouDie.Count; i++)
        {
            Debug.Log("Notifying " + AIToNotifyWhenYouDie[i].name);
            MovementAI AIToNotify = AIToNotifyWhenYouDie[i].GetComponent <MovementAI>();
            if (AIToNotify != null)
            {
                AIToNotify.NotifyOfDeath(this.gameObject);
            }
            else
            {
                TurretAI TurretToNotify = AIToNotifyWhenYouDie[AIToNotifyWhenYouDie.Count - 1].GetComponent <TurretAI>();
                if (TurretToNotify != null)
                {
                    TurretToNotify.NotifyOfDeath(this.gameObject);
                }
            }
        }

        playerFlagHolder.DropFlags();
        Invoke("Respawn", respawnTime);
    }
Example #2
0
    void OnCollisionEnter(Collision col)
    {
        BaseShip    bs = col.gameObject.GetComponent <BaseShip> ();
        Destroyable ds = col.gameObject.GetComponent <Destroyable> ();

        if (bs == whoFiredMe)
        {
            return;
        }
        if (bs != null)
        {
            if (col.collider.CompareTag("Turret"))
            {
                TurretAI ta = col.collider.GetComponent <TurretAI> ();
                if (ta != null)
                {
                    ta.Damage(damage, whoFiredMe);
                }
            }
            else if (col.collider.CompareTag("Weak"))
            {
                bs.Damage(damage * 2, whoFiredMe);
            }
            else
            {
                bs.Damage(damage, whoFiredMe);
            }
        }
        else if (ds != null)
        {
            ds.Damage(damage);
        }
    }
Example #3
0
    /// <summary>
    /// Sets up Transport stats, as well as its turret params
    /// </summary>
    /// <seealso cref="TurretAI"/>
    private void Awake()
    {
        // Set APC stats.
        _myCombatController = gameObject.GetComponent <CombatController>();
        _myRigidBody        = gameObject.GetComponent <Rigidbody2D>();

        _myCombatController.SetMaxHealth(maxHealth);
        _myCombatController.SetDebris(deathDebris);

        CombatController foreTurretCombatController = foreTurret.GetComponent <CombatController>();
        TurretAI         foreTurretAI = foreTurret.GetComponent <TurretAI>();

        CombatController aftTurretCombatController = aftTurret.GetComponent <CombatController>();
        TurretAI         aftTurretAI = aftTurret.GetComponent <TurretAI>();

        // Set combat stats for Fore Turret.
        foreTurretCombatController.SetWeaponRange(weaponRange);
        foreTurretCombatController.SetWeaponDelay(weaponDelay);
        foreTurretCombatController.SetWeaponAccuracy(weaponAccuracy);
        foreTurretCombatController.SetWeaponDamage(weaponDamage);
        foreTurretCombatController.SetWeaponMunition(weaponMunitionPrefab);
        foreTurretAI.SetAttackRange(attackRange);

        // Set combat stats for Aft Turret.
        aftTurretCombatController.SetWeaponRange(weaponRange);
        aftTurretCombatController.SetWeaponDelay(weaponDelay);
        aftTurretCombatController.SetWeaponAccuracy(weaponAccuracy);
        aftTurretCombatController.SetWeaponDamage(weaponDamage);
        aftTurretCombatController.SetWeaponMunition(weaponMunitionPrefab);
        aftTurretAI.SetAttackRange(attackRange);
    }
Example #4
0
    private void Start()
    {
        var SC = GetComponent <SphereCollider>();

        SC.isTrigger = true;
        SC.radius    = MaxDetectionDistance;
        TurretAI     = GetComponent <TurretAI>();
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     turretScript = turretPrefab.GetComponent <TurretAI>();
     buttonText   = GetComponentInChildren <Text>();
     button       = GetComponent <Button>();
     //turretIcon = turretScript.turretIcon;
     //button.image = turretIcon;
     buttonText.text = turretScript.turretName + "\n $" + turretScript.cost;
     button.onClick.AddListener(Build);
 }
Example #6
0
    void OnSceneGUI()
    {
        TurretAI fov = (TurretAI)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(fov.transform.position, Vector3.up, Vector3.forward, 360, fov.viewRadius);
        Handles.color = Color.red;
        Handles.DrawWireArc(fov.transform.position, Vector3.up, Vector3.forward, 360, fov.viewRadius / 3);
        Vector3 viewAngleA = fov.DirFromAngle(-fov.viewAngle / 2, false);
        Vector3 viewAngleB = fov.DirFromAngle(fov.viewAngle / 2, false);

        Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleA * fov.viewRadius);
        Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleB * fov.viewRadius);
    }
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timer += Time.deltaTime;
        TurretAI script = animator.GetComponent <TurretAI>();

        if (script.TargetIsVisible())
        {
            animator.SetTrigger("TrackingState");
        }
        else
        {
            float rotationValue = Mathf.Cos(timer) * rotationMax;
            script.transform.Rotate(0, rotationValue, 0);
        }
    }
Example #8
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timer += Time.deltaTime;
        TurretAI script = animator.GetComponent <TurretAI>();

        script.transform.LookAt(script.seekObject.transform);
        if (timer >= timeToFire)
        {
            FindObjectOfType <KinematicInput>().HealthChange(5);
            timer = 0.0f;
        }
        else if (!script.TargetIsVisible())
        {
            animator.SetTrigger("SearchingState");
            timer = 0.0f;
        }
    }
    // Update is called once per frame
    void Update()
    {
        Ray        rayRadius = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitTower;

        if (Physics.Raycast(rayRadius, out hitTower) && hitTower.collider.gameObject == ThisTowerHead)
        {
            TAI = ThisTowerHead.GetComponent <TurretAI>();
            Vector3 tScale = new Vector3(TAI.attackMaxDistance, 0.02f, TAI.attackMaxDistance);
            ThisObj.localScale = tScale;
            rend.enabled       = true;
            //Rotate Turret Radius
            this.transform.Rotate(Vector3.up, Time.deltaTime * 10);
        }
        else
        {
            rend.enabled = false;
        }
    }
Example #10
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy enemy = hitInfo.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }
        TurretAI turretAI = hitInfo.GetComponent <TurretAI>();

        if (turretAI != null)
        {
            turretAI.TakeDamage1(damage);
        }
        AIenyme aIenyme = hitInfo.GetComponent <AIenyme>();

        if (aIenyme != null)
        {
            aIenyme.TakeDamage2(damage);
        }
        BossHealth enemy1 = hitInfo.GetComponent <BossHealth>();

        if (enemy1 != null)
        {
            enemy1.TakeDamage3(damage);
        }
        Enemyhealmap3 enemybossmap3 = hitInfo.GetComponent <Enemyhealmap3>();

        if (enemybossmap3 != null)
        {
            enemybossmap3.TakeDamage(damage);
        }

        Instantiate(impactEffect, transform.position, transform.rotation);
        Destroy(gameObject);
    }
Example #11
0
 void Awake()
 {
     turretAI = gameObject.GetComponentInParent<TurretAI> ();
 }
Example #12
0
 void Awake()
 {
     turretAI = gameObject.GetComponentInParent <TurretAI>();
 }
Example #13
0
 // Use this for initialization
 void Start()
 {
     turretAI = gameObject.GetComponentInParent <TurretAI>();
 }
 void Awake() // When turret awakes get TurretAI
 {
     turretAI = gameObject.GetComponentInParent <TurretAI>();
 }
Example #15
0
 void SetParameters()
 {
     NA.speed = Speed;
     TurretAI = GetComponent <TurretAI>();
 }
Example #16
0
 // Use this for initialization
 void Start()
 {
     ai_controller = GetComponentInParent <AIController>();
     turret_ai     = GetComponentInParent <TurretAI>();
     StartCoroutine("FindTargetsWithDelay", .2f);
 }
Example #17
0
 private void Awake()
 {
     //Inherit all the component in class TurretAI
     turret = gameObject.GetComponentInParent <TurretAI>();
 }
Example #18
0
    public override void OnInspectorGUI()
    {
        TurretAI   script  = (TurretAI)target;
        GUIContent tooltip = new GUIContent("", "");

        // Show general information options
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("General:", EditorStyles.boldLabel);
        tooltip = new GUIContent("Rotation Piece:", "The part of the turret that will rotate to look towards the target");
        script.rotationPiece = (Transform)EditorGUILayout.ObjectField(tooltip, script.rotationPiece, typeof(Transform), true);
        tooltip           = new GUIContent("Search Mode:", "Will the turret search randomly using the old search method, or scan point to point in a sweeping motion?");
        script.searchMode = (TURRET_SEARCH_TYPE)EditorGUILayout.EnumPopup(tooltip, script.searchMode);
        if (script.searchMode == TURRET_SEARCH_TYPE.PointToPoint)
        {
            tooltip            = new GUIContent("   Search Angle:", "The angle the turret will sweep to, where 0 is straight ahead");
            script.searchAngle = EditorGUILayout.Slider(tooltip, script.searchAngle, 0.0f, 90.0f);
            tooltip            = new GUIContent("   Rotation Pause:", "Time in seconds the turret will stop rotating for at the end of each directional sweep");
            script.pauseTime   = EditorGUILayout.Slider(tooltip, script.pauseTime, 0.0f, 1.5f);
        }
        tooltip            = new GUIContent("Vision Angle:", "Angle in degrees the turret can see the target");
        script.visionAngle = EditorGUILayout.Slider(tooltip, script.visionAngle, 40.0f, 90.0f);

        tooltip  = new GUIContent("Invisible Tags", "A list of tags the turret can see through");
        showTags = EditorGUILayout.Foldout(showTags, tooltip);
        if (showTags)
        {
            for (int i = 0; i < script.seeThroughTags.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("-", GUILayout.Width(23)))
                {
                    script.seeThroughTags.RemoveAt(i);
                }
                else
                {
                    script.seeThroughTags[i] = EditorGUILayout.TextField(script.seeThroughTags[i]);
                }

                EditorGUILayout.EndHorizontal();
            }
            if (script.seeThroughTags.Count > 0)
            {
                EditorGUILayout.Space();
            }
            if (GUILayout.Button("+", GUILayout.Width(23)))
            {
                script.seeThroughTags.Add("");
            }
            EditorGUILayout.Space();
        }

        // Show gun information options
        EditorGUILayout.LabelField("Guns:", EditorStyles.boldLabel);
        tooltip = new GUIContent("Auto Populate List:", "If checked, the script will automatically find and use all guns attached to the turret. Otherwise you can specify specific gun scripts to be used");
        script.autoPopulateGunList = EditorGUILayout.Toggle(tooltip, script.autoPopulateGunList);

        if (!script.autoPopulateGunList)
        {
            // Show gun list so it can be manually modified
            tooltip     = new GUIContent("Guns", "A list of attached guns the turret will use");
            showGunList = EditorGUILayout.Foldout(showGunList, tooltip);
            if (showGunList)
            {
                for (int i = 0; i < script.guns.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("-", GUILayout.Width(23)))
                    {
                        script.guns.RemoveAt(i);
                    }
                    else
                    {
                        script.guns[i] = (WeaponBase)EditorGUILayout.ObjectField("", script.guns[i], typeof(WeaponBase), true);
                    }

                    EditorGUILayout.EndHorizontal();
                }
                if (script.seeThroughTags.Count > 0)
                {
                    EditorGUILayout.Space();
                }
                if (GUILayout.Button("+", GUILayout.Width(23)))
                {
                    script.guns.Add(default(WeaponBase));
                }
                EditorGUILayout.Space();
            }
        }

        tooltip           = new GUIContent("Shoot Delay:", "Delay in seconds before the turret will shoot, after obtaining a direct view to it's target");
        script.shootDelay = EditorGUILayout.Slider(tooltip, script.shootDelay, 0.0f, 3.0f);

        // Show aim options
        EditorGUILayout.LabelField("Aiming:", EditorStyles.boldLabel);
        tooltip = new GUIContent("Tracking Range:", "View distance of the turret");
        script.trackingRange = EditorGUILayout.Slider(tooltip, script.trackingRange, 10.0f, 500.0f);
        tooltip               = new GUIContent("Aim-Up Clamp:", "Max angle the turret can look up");
        script.clampAngleUp   = EditorGUILayout.Slider(tooltip, script.clampAngleUp, 0.0f, 88.0f);
        tooltip               = new GUIContent("Aim-Down Clamp:", "Max angle the turret can look down");
        script.clampAngleDown = EditorGUILayout.Slider(tooltip, script.clampAngleDown, 0.0f, 88.0f);
        tooltip               = new GUIContent("Rotation Speed:", "The speed the turret will rotate at");
        script.rotateSpeed    = EditorGUILayout.Slider(tooltip, script.rotateSpeed, 1.0f, 10.0f);
    }