Inheritance: MonoBehaviour
Beispiel #1
0
    protected void tickSteering()
    {
        if (isMoving)
        {
            float t = moveSpeed / moveStepDistance;
            moveLerpFactor += (Time.deltaTime * t);
            if (moveLerpFactor > 1.0f)
            {
                moveLerpFactor = 1.0f;
            }
            transform.localPosition = Vector3.Lerp(siteStartToMove, targetToMove, moveLerpFactor);
            if (moveLerpFactor == 1.0f)
            {
                isMoving = false;
            }
        }

        if (isRotating)
        {
            float spinFactor = 0.0f;
            currentOrientation = TurretController.cuteRotate(currentOrientation, targetToRotate, rotateSpeed, out spinFactor);
            if (spinFactor == 0.0f)
            {
                isRotating = false;
            }
            else
            {
                isRotating = true;
            }

            transform.localRotation = Quaternion.Euler(0, currentOrientation, 0);
        }
    }
    private void OnEnable()
    {
        instance = target as TurretController;

        (HitOptFlg = new AnimBool(instance.HIT_RESPONSE != EnemyAIAgent.HitResponse.Invincible)).valueChanged.AddListener(Repaint);
        (HitOptDisableFlg = new AnimBool(instance.HIT_RESPONSE == EnemyAIAgent.HitResponse.Disable)).valueChanged.AddListener(Repaint);

        BARBETTE = serializedObject.FindProperty("BARBETTE");

        ProjectilePrefab = serializedObject.FindProperty("ProjectilePrefab");
        PROJ_SPAWN       = serializedObject.FindProperty("PROJ_SPAWN");
        PROJECTILE_SPEED = serializedObject.FindProperty("PROJECTILE_SPEED");
        FIRE_DELAY       = serializedObject.FindProperty("FIRE_DELAY");
        MAX_RANGE        = serializedObject.FindProperty("MAX_RANGE");

        MAX_THETA = serializedObject.FindProperty("MAX_THETA");
        ROT_SPEED = serializedObject.FindProperty("ROT_SPEED");

        FireSound   = serializedObject.FindProperty("FireSound");
        SoundSource = serializedObject.FindProperty("SoundSource");

        HitResponse  = new EnumPropertyField(instance, "HIT_RESPONSE");
        HealthBar    = serializedObject.FindProperty("HealthBar");
        HPCap        = serializedObject.FindProperty("HPCap");
        HPLeft       = serializedObject.FindProperty("HPLeft");
        DISABLE_TIME = serializedObject.FindProperty("DISABLE_TIME");
    }
Beispiel #3
0
 private void InitializeComponent()
 {
     cognitiveMoveTarget  = GetComponent <CognitiveMoveTarget>();
     cognitiveShootTarget = GetComponent <CognitiveShootTarget>();
     tankController       = GetComponent <TankController>();
     turretController     = transform.root.GetComponentInChildren <TurretController>();
 }
Beispiel #4
0
//Disable all turrets on rotate, then recheck each side for matches.
//Activate turrets based on number of Match-3s on a given side.
    void Activator()
    {
        //Find each block in the runway and effect changes on that block's children (turrets)
        GridInUse[] runway = FindObjectsOfType(typeof(GridInUse)) as GridInUse[];
        foreach (GridInUse child in runway)
        {
            TurretController childTwo = child.GetComponentInChildren <TurretController>();
            if (childTwo != null)
            {
                childTwo.isActivated = false;
                if (child.transform.localPosition.x > 0 && child.transform.localPosition.x <= (Mathf.CeilToInt(greenValue.sliderValue / 5)) * 2)
                {
                    childTwo.SetTurretActive("GreenTurret");
                }

                if (child.transform.localPosition.x > 0 && child.transform.localPosition.x <= (Mathf.CeilToInt(redValue.sliderValue / 5)) * 2)
                {
                    childTwo.SetTurretActive("RedTurret");
                }

                if (child.transform.localPosition.x > 0 && child.transform.localPosition.x <= (Mathf.CeilToInt(blueValue.sliderValue / 5)) * 2)
                {
                    childTwo.SetTurretActive("BlueTurret");
                }
            }
        }
    }
Beispiel #5
0
    public override void Start(RAIN.Core.AI ai)
    {
        base.Start(ai);

        _lastRunning       = 0;
        m_TurretController = ai.Body.GetComponent <TurretController>();
    }
Beispiel #6
0
 public override void Start(RAIN.Core.AI ai)
 {
     base.Start(ai);
     m_Angle = 0.0f;
     m_TurretController = ai.Body.GetComponent<TurretController>();
     m_Turret = m_TurretController.m_ShellSpawner.transform.parent.gameObject;
 }
 private void Awake()
 {
     turretController                = GetComponent <TurretController>();
     turretController.onFire        += HandleFire;
     turretController.onSwitchWeaon += HandleSwitchWeapon;
     SwitchWeapon(0);
 }
Beispiel #8
0
    public override void Start(RAIN.Core.AI ai)
    {
        base.Start(ai);

        _lastRunning = 0;
        m_TurretController = ai.Body.GetComponent<TurretController>();
    }
Beispiel #9
0
    //Return null if nobody is within its range
    public EnemyController GetEnemy(TurretController t, float range)
    {
        Wave w = WaveSpawner.CurrentWave;

        List <EnemyController> enemiesInRange = new List <EnemyController>();

        foreach (EnemyController e in w.CurrentEnemies)
        {
            if (e.View.Instance != null)
            {
                float distanceToEnemy = Utils.GetDistanceToEnemy(t, e);
                if (distanceToEnemy < range)
                {
                    enemiesInRange.Add(e);
                }
            }
        }
        if (enemiesInRange.Count > 0)
        {
            int enemyIndex = Random.Range(0, enemiesInRange.Count - 1);
            Debug.Log("index = " + enemyIndex);
            return(enemiesInRange[enemyIndex]);
        }
        else
        {
            return(null);
        }
    }
Beispiel #10
0
 public override void Start(RAIN.Core.AI ai)
 {
     base.Start(ai);
     actionName         = "Attack";
     m_TurretController = ai.Body.GetComponent <TurretController>();
     m_Turret           = m_TurretController.m_ShellSpawner.transform.parent.gameObject;
 }
    // sets all values for TurretController script using turretData, adds "click-icon-to-buy" function, changes visual cues to see if turret is bought
    private void SetValues(GameObject turret)
    {
        TurretController script = turret.GetComponent <TurretController>();  // script setup

        script.turretData = turretData;
        script.UpdateVariables();
        Transform newShootpoint = new GameObject("Shootpoint").transform;

        newShootpoint.SetParent(turret.transform);
        script.shootPoint = newShootpoint;
        script.shootPoint.localPosition = new Vector2(turretData.shootpointOffsetX, 0);
        script.targetTag = "Enemy";
        script.bullet    = turretData.bullet;
        script.enabled   = false;

        turret.transform.localPosition = Vector2.zero;                // moving turret to middle of tower block

        SpriteRenderer rend = turret.GetComponent <SpriteRenderer>(); // setting up sprite (half transparent, sorting order)

        rend.sprite       = turretData.artwork;
        rend.color        = new Color(1, 1, 1, 0.5f);
        rend.sortingOrder = towerCount + 1;
        turret.GetComponent <BoxCollider2D>().size      = new Vector2(1, 1);
        turret.GetComponent <BoxCollider2D>().isTrigger = true;

        TurretButton turrButScript = turret.GetComponent <TurretButton>();   // setting up fake turret button ("click-icon-to-buy" without using UI buttons)

        turrButScript.values         = values;
        turrButScript.towerPlacement = this;
        turrButScript.index          = towerCount;
    }
Beispiel #12
0
    /**
     * Une tourelle est fixée à une case
     * */
    private void BuildTurret()
    {
        TurretModel turretToBuild = BuildManager.GetInstance().GetTurretToBuild();

        if (turret != null)
        {
            Debug.Log("Can't build there !");
            return;
        }
        else if (GameController.Pay(turretToBuild.Price) != -1)
        {
            Vector3 spawnPosition = new Vector3(transform.position.x, 0.7f, transform.position.z);

            Debug.Log("Turret to build : " + turretToBuild);
            TurretController turretBuilt = new TurretController(turretToBuild, spawnPosition, this.transform);

            turret = turretBuilt;
        }
        else
        {
            //Not enough money
            Debug.Log("Not enough money");
            rend.material.color = errorColor;
        }
    }
Beispiel #13
0
    private void OnPlayerSpawn(GameObject player)
    {
        m_controlledTurret = player.GetComponentInChildren <TurretController>();
        player.GetComponent <Destructible>().OnDeath += OnPlayerDeath;

        m_gameManager.NotifyPlayerSpawn -= OnPlayerSpawn;
    }
Beispiel #14
0
    public void  Init(InstanceNetType nettype, TurretController mouseturret, TankFire tankfire)
    {
        if (BaseInitSystem.isBot(nettype))
        {
            this.enabled = false;
            return;
        }

        turretController = mouseturret;
        netType          = nettype;
        tankFire         = tankfire;
        if (!BaseInitSystem.isBot(nettype))
        {
            if (transform.root.GetComponentInChildren <PlayerState> ().IsMobile == true && transform.root.GetComponentInChildren <PlayerState> ().Mine)
            {
                transform.root.GetComponentInChildren <PlayerState> ().userUI.MG.triggers.Add(PlayerState.MyEntry(SwtichStartFire, UnityEngine.EventSystems.EventTriggerType.BeginDrag));
                transform.root.GetComponentInChildren <PlayerState> ().userUI.MG.triggers.Add(PlayerState.MyEntry(SwtichStartFire, UnityEngine.EventSystems.EventTriggerType.Drag));
                transform.root.GetComponentInChildren <PlayerState> ().userUI.MG.triggers.Add(PlayerState.MyEntry(SwtichEndFire, UnityEngine.EventSystems.EventTriggerType.PointerUp));
            }
        }


        Bullet = (GameObject)Resources.Load("Ammos/Ammo_13mm");


        Forward = new GameObject("Forward");
        Forward.transform.SetParent(MachineGunFFPoint.parent);
        Forward.transform.localPosition = Vector3.zero;
        Forward.transform.eulerAngles   = MachineGunFFPoint.eulerAngles;

        GameObject AmmoInfo = Instantiate(Bullet);

        AmmoInfo.GetComponent <BulletScript> ().bulletState = BulletState.Info;
        AmmoInfo.transform.position = Vector3.zero;
    }
 public void ChangeTurretMode(TurretController turret, int expectedTurretType)
 {
     if (turret.modes.GetTurretType(turret) == expectedTurretType)
     {
         turret.modes.ToggleMode(turret);
     }
 }
 void OnTriggerExit(Collider objectHit)
 {
     if (objectHit.name.StartsWith("Turret"))
     {
         TurretController theTurret = objectHit.GetComponent <TurretController>();
         theTurret.firing = false;
     }
 }
Beispiel #17
0
 void Start()
 {
     foreach (Transform child in transform)
     {
         TurretController turret = child.GetChild(1).GetComponent <TurretController>();
         turretList.Add(turret);
     }
 }
Beispiel #18
0
    // Use this for initialization

    public void InitItem()
    {
        audio_manager     = GameObject.FindGameObjectWithTag("Audio_Manager").GetComponent <AudioManager>();
        turret_controller = GameObject.FindGameObjectWithTag("Cannon").GetComponent <TurretController>();

        life_time = 0.0f;
        available = true;
    }
 void Start()
 {
     currentActiveTurret = turretManager.GetStartingTurret(3);
     currentActiveCamera = turretManager.GetPlayerCamera(3);
     AdjustTurretSettings();
     currentActiveCamera.Activate();
     currentActiveTurret.ActivateTurret();
 }
 /**
  * Updates the barrel's aim.
  */
 void FixedUpdate()
 {
     if (parentController == null)
     {
         parentController = GetParentController();
     }
     AimAtTarget();
 }
Beispiel #21
0
 public void Start()
 {
     SkillList = new List <ISkill>();
     _radar    = gameObject.GetComponentInChildren <FieldOfViewController2D>();
     _turret   = gameObject.GetComponentInChildren <TurretController>();
     _player   = GameObject.FindGameObjectWithTag("CharCollisionBody");
     SkillList.Add(new Shot(gameObject.GetComponentInChildren <ProjectileLauncher2D>()));
 }
Beispiel #22
0
    public bool CouldShoot(MovementController ctr)
    {
        TurretController ltr = ctr as TurretController;

        bool shootDelayOK = (Time.time > ltr.lastShootTime + this.turretData.shootDelay);
        bool aimDelayOK   = (Time.time > ltr.aimStartTime + this.turretData.aimDuration);

        return(shootDelayOK && aimDelayOK);
    }
 private void Awake()
 {
     _healthBar         = GetComponentInChildren <Slider>();
     _currentHealth     = StartingHealth;
     _chassisController = GetComponent <ChassisController>();
     _turretController  = GetComponentInChildren <TurretController>();
     _cannonController  = GetComponentInChildren <CannonController>();
     _teslaShield       = GetComponentInChildren <TeslaShield>();
 }
Beispiel #24
0
 void ClearTurret()
 {
     if (turret != null)
     {
         turret.GetComponent <SpriteRenderer>().color = Color.white;
         turret = null;
         ToggleBuildUI(false);
     }
 }
Beispiel #25
0
    // Start is called before the first frame update
    void Start()
    {
        minimumDelay = TurretFireRateDelayHolder.turretDelayStaticMin;
        maximumDelay = TurretFireRateDelayHolder.turretDelayStaticMax;

        fireRate = Random.Range(minimumDelay, maximumDelay);

        cooldownCounter  = 0f;
        turretController = GetComponent <TurretController>();
    }
    protected override void Initialize()
    {
        base.Initialize();

        sphereCollider   = GetComponent <SphereCollider>();
        trailRenderer    = GetComponent <TrailRenderer>();
        turretController = BattleRoot.BattleController.TurretController;

        idleState   = new IdleState(this);
        thrownState = new ThrownState(this);
    }
Beispiel #27
0
 // Use this for initialization
 void Start()
 {
     Bullet              = Resources.Load <GameObject>("Prefabs/Bullet");
     OwnController       = gameObject.GetComponentInParent <TurretController>();
     _firingRate         = TurretConfig._FiringRate;
     _damage             = TurretConfig._Damage;
     _bulletSpeed        = TurretConfig._BulletSpeed;
     _interactAreaRadius = TurretConfig._InteractAreaRadius;
     interactController  = gameObject.GetComponentInParent <InteractController>();
     interactController.InteractRadius = _interactAreaRadius;
     Targets = new List <Collider2D>();
 }
Beispiel #28
0
    public void ToggleMode(TurretController turret)
    {
        int[] targetModes = GameManager.Instance.globalModeManager.targetModes;

        if (targetModes.Length == 0)
        {
            Debug.Log("Increase number of modes.");
            return;
        }
        mode = targetModes[mode % targetModes.Length];
        SetTurretMode(mode, turret.transform);
    }
Beispiel #29
0
    public IEnumerator Aim(MovementController ctr)
    {
        TurretController ltr = ctr as TurretController;

        ltr.aimStartTime = Time.time;
        if (ltr.target == null)
        {
            ltr.target = this.snake;
        }

        yield return(ltr.AimAtTarget());
    }
Beispiel #30
0
    // Start is called before the first frame update
    void Awake()
    {
        mark_enemystart = GameObject.Find("mark_enemystart");
        mark_home       = GameObject.Find("mark_home");

        turretController = GameObject.Find("TurretSelectUI").GetComponent <TurretController>();

        mapController   = gameObject.GetComponent <MapController>();
        enemyStart      = mapController.WorldToCell(mark_enemystart.transform.position);
        home            = mapController.WorldToCell(mark_home.transform.position);
        enemyStart_wPos = mark_enemystart.transform.position;
        home_wPos       = mark_home.transform.position;

        enemyList = new List <EnemyScript>();

        if (PlayerInfo.instance.level == 2)
        {
            enemyGoldColor = Color.white;
        }
        else
        {
            enemyGoldColor = Color.black;
        }

        maoyu     = Resources.Load <GameObject>("Prefabs/enemies/enemy_maoyu");
        cirno     = Resources.Load <GameObject>("Prefabs/enemies/enemy_cirno");
        rumia     = Resources.Load <GameObject>("Prefabs/enemies/enemy_rumia");
        meilin    = Resources.Load <GameObject>("Prefabs/enemies/enemy_meilin");
        sakuya    = Resources.Load <GameObject>("Prefabs/enemies/enemy_sakuya");
        patchouli = Resources.Load <GameObject>("Prefabs/enemies/enemy_patchouli");
        remilia   = Resources.Load <GameObject>("Prefabs/enemies/enemy_remilia");
        flandre   = Resources.Load <GameObject>("Prefabs/enemies/enemy_flandre");
        alice     = Resources.Load <GameObject>("Prefabs/enemies/enemy_alice");
        shanghai  = Resources.Load <GameObject>("Prefabs/enemies/enemy_shanghai");
        chen      = Resources.Load <GameObject>("Prefabs/enemies/enemy_chen");
        rin       = Resources.Load <GameObject>("Prefabs/enemies/enemy_rin");
        sanae     = Resources.Load <GameObject>("Prefabs/enemies/enemy_sanae");
        aya       = Resources.Load <GameObject>("Prefabs/enemies/enemy_aya");
        kaguya    = Resources.Load <GameObject>("Prefabs/enemies/enemy_kaguya");
        yuugi     = Resources.Load <GameObject>("Prefabs/enemies/enemy_yuugi");

        kanako      = Resources.Load <GameObject>("Prefabs/enemies/enemy_kanako");
        suwako      = Resources.Load <GameObject>("Prefabs/enemies/enemy_suwako");
        yuuka       = Resources.Load <GameObject>("Prefabs/enemies/enemy_yuuka");
        suika       = Resources.Load <GameObject>("Prefabs/enemies/enemy_suika");
        suika_small = Resources.Load <GameObject>("Prefabs/enemies/enemy_suika_small");
        youmu       = Resources.Load <GameObject>("Prefabs/enemies/enemy_youmu");
        yuyuko      = Resources.Load <GameObject>("Prefabs/enemies/enemy_yuyuko");

        eirin    = Resources.Load <GameObject>("Prefabs/enemies/enemy_eirin");
        yukari   = Resources.Load <GameObject>("Prefabs/enemies/enemy_yukari");
        shikieki = Resources.Load <GameObject>("Prefabs/enemies/enemy_shikieki");
    }
Beispiel #31
0
 void Start()
 {
     Player      = FindObjectOfType <TurretController>();
     Target      = GameObject.FindGameObjectWithTag("Flower").transform;
     rb          = GetComponent <Rigidbody2D>();
     bar         = GetComponentInChildren <HealthBar>();
     Health      = MaxHealth;
     AttackSpeed = AttacksPerSecond / 1;
     Physics2D.IgnoreLayerCollision(8, 8);
     controller  = FindObjectOfType <GameController>();
     audioSource = GetComponent <AudioSource>();
 }
Beispiel #32
0
    private int SphereCastTowards(TurretController ltr, Vector3 towards, LayerMask mask, float radius)
    {
        Vector3 origin;
        float   dist;
        int     count;

        origin = ltr.turret.muzzle.position;
        dist   = this.turretData.rangeOfView + 1f;

        count = Physics.SphereCastNonAlloc(origin, radius, towards, this.raycastResults, dist, mask);

        return(count);
    }
Beispiel #33
0
 public override void Start(RAIN.Core.AI ai)
 {
     base.Start(ai);
     actionName = "KeepTargetInRange";
     m_TurretController = ai.Body.GetComponent<TurretController>();
 }
Beispiel #34
0
    public bool init()
    {
        //< for bt debug
        base.Init();
        this.SetIdFlag(1);

        transform.localRotation = Quaternion.Euler(0, currentOrientation, 0);
        // find turret and barrel
        Transform turretTransform = null;
        for(int i = 0; i < transform.childCount; ++i)
        {
            Transform child = transform.GetChild(i);
            if(child.name == "Turret")
            {
                turretTransform = child;
                for(int k = 0; k < turretTransform.transform.childCount; ++k)
                {
                    Transform childOfTurret = turretTransform.GetChild(k);
                    if(childOfTurret.name == "FirePoint")
                    {
                        firePoint = childOfTurret;
                        break;
                    }
                    //<
                }
            }
            else if(child.name == "Anchor")
            {
                anchorNode = child;
            }
        }

        if(turretTransform != null)
        {
            turretCtrl = new TurretController();
            turretCtrl.turret = turretTransform;
        }

        anchorNode.transform.DetachChildren();
        GameObject flagPrefab = null;
        if(force == eGameForce.RED_FORCE)
            flagPrefab = Resources.Load("Prefabs/ForceFlagRed") as GameObject;
        else
            flagPrefab = Resources.Load("Prefabs/ForceFlagBlue") as GameObject;

        GameObject flagInstance = GameObject.Instantiate(flagPrefab) as GameObject;
        flagInstance.transform.parent = anchorNode;
        flagInstance.transform.localPosition = Vector3.zero;
        flagInstance.transform.localRotation = Quaternion.identity;

        meshTable = new Hashtable();
        gatherMeshes();

        if(behaviorTree.Length > 0)
        {
            btloadResult = btload(behaviorTree, true);
            if(btloadResult)
                btsetcurrent(behaviorTree);
            else
                Debug.LogError("Behavior tree data load failed! " + behaviorTree);
        }

        bubbleHud = BubbleHud.createBubbleHud(this);

        //< todo: trick
        int life = playerLifeCount;
        playerLifeCount = life;

        targetToMove = transform.localPosition;
        gameScore = calcGameScore();

        return true;
    }