コード例 #1
0
ファイル: FlexCam.cs プロジェクト: Tobomabas/unityTest
        protected virtual void CheckLockOnTarget(LockOnTarget t)
        {
            if (t == null || Player == null)
            {
                return;
            }
            if (t.Target == null)
            {
                if (lockOnTargets.Contains(t))
                {
                    lockOnTargets.Remove(t);
                }
                return;
            }

            if (t.Active)
            {
                if (Vector3.Distance(Player.transform.position, t.TargetPosition) > t.Range * GetManualScaleMod() * (1 + LockonBufferMod))
                {
                    t.Active = false;
                }
            }
            else
            {
                if (!t.Returning)
                {
                    lockOnTargets.Remove(t);
                }
                else if (t.Returning && Vector3.Distance(Player.transform.position, t.TargetPosition) <= t.Range * GetManualScaleMod())
                {
                    t.Active = true;
                }
            }
        }
コード例 #2
0
    //coroutine that finds enemies
    IEnumerator AcquireLockOn()
    {
        yield return(new WaitForSeconds(startWait));

        //while the number of marks applied is under the maximum and the button is still held down
        while (lockOnCount < ps.lockOnMax && lockingOn)
        {
            //scan for targets
            tir.ScanInSphere();

            //if targets were found
            if (tir.targetsInRange.Count > 0)
            {
                //apply a mark to all targets found
                foreach (Collider c in tir.targetsInRange)
                {
                    if (lockOnCount < ps.lockOnMax)
                    {
                        LockOnTarget l = c.gameObject.GetComponent <LockOnTarget> ();
                        l.lockedOn++;
                        lockOnCount++;
                    }
                }
                ;
            }

            //update text, then wait
            lockonCounter.text = lockOnCount.ToString();
            yield return(new WaitForSeconds(ps.lockOnRate));
        }
        yield break;
    }
コード例 #3
0
ファイル: RaserPointer.cs プロジェクト: kazu-f/SKY_SHOOTER
 // Start is called before the first frame update
 void Start()
 {
     //照準を作成。
     AIMTarget = Instantiate(AIMTargetRenderer, transform);
     gameObject.AddComponent <LineRenderer>();
     raserPointer            = GetComponent <LineRenderer>();
     m_lockOn                = gameObject.GetComponent <LockOnTarget>();
     raserPointer.startWidth = LINE_WEIDTH;
     raserPointer.endWidth   = LINE_WEIDTH;
     raserPointer.material   = new Material(Shader.Find("Sprites/Default"));
 }
コード例 #4
0
ファイル: FlexCam.cs プロジェクト: Tobomabas/unityTest
        /// <summary> Removes a permanent LockOn target. Does nothing if it's not a permanent LockOn target. </summary>
        public virtual void RemovePermanentLockOn(GameObject target)
        {
            if (target == null)
            {
                return;
            }
            LockOnTarget t = lockOnTargets.Find(j => j.Permanent && j.Target == target);

            CheckLockOnTarget(t);
            if (t != null)
            {
                lockOnTargets.Remove(t);
            }
        }
コード例 #5
0
ファイル: FlexCam.cs プロジェクト: Tobomabas/unityTest
        protected virtual void AddPermLockOn(GameObject target, float focus, float range)
        {
            if (target == null || target == Player)
            {
                return;
            }
            LockOnTarget t = new LockOnTarget(target, true, true, focus, range);

            CheckLockOnTarget(t);
            if (t != null)
            {
                lockOnTargets.Add(t);
            }
        }
コード例 #6
0
ファイル: FlexCam.cs プロジェクト: Tobomabas/unityTest
        protected virtual void SetTempLockOn(GameObject target, bool returning, float focus, float range)
        {
            if (target == null || target == Player)
            {
                return;
            }
            LockOnTarget t = new LockOnTarget(target, false, returning, focus, range);

            t.Active = true;
            CheckLockOnTarget(t);
            if (t != null)
            {
                lockOnTargets.Add(t);
                StopOtherTemporaryLockOns(target);
            }
        }
コード例 #7
0
    void LockOnProcess(float fH)
    {
        if (m_input != null)
        {
            if (!IsLockOn)
            {
                if (m_input.InputData.btnInputs[(int)InputIndex.AXIS_R])
                {
                    m_targetDetect.TargetDetection();
                    LockOnTarget = m_targetDetect.GetTarget();

                    if (LockOnTarget != null)
                    {
                        m_lockOnTrans = LockOnTarget.GetTransform();
                        if (m_lockOnBill != null)
                        {
                            m_lockOnBill.SetActive(true);
                            //m_lockOnGo.transform.parent = m_lockOnTrans;
                        }
                    }
                }
            }
            else
            {
                if (m_input.InputData.btnInputs[(int)InputIndex.AXIS_R])
                {
                    TarGetClear();
                    return;
                }

                if (Mathf.Abs(m_input.InputData.rightAxisX) > 0.1f || Input.GetKeyDown(KeyCode.Z))
                {
                    Transform changeTrans = LockOnTarget.GetTransform(true);

                    if (changeTrans != m_lockOnTrans)
                    {
                        m_lockOnTrans = changeTrans;
                        return;
                    }

                    LockOnTarget  = m_targetDetect.CanTargetChange(true);
                    m_lockOnTrans = LockOnTarget.GetTransform();
                }
            }
        }
    }
コード例 #8
0
    //the function called when the fire button is released
    public bool Fire()
    {
        //disable the flags raised in LockOn() and stop locking on
        lockingOn                 = false;
        lockOnZone.enabled        = false;
        lockOnZoneVisible.enabled = false;
        StopCoroutine(AcquireLockOn());

        //for every target that was found during lock on
        foreach (Collider c in tir.targetsInRange)
        {
            //access their LockOnTarget script attached to them
            LockOnTarget l = c.gameObject.GetComponent <LockOnTarget> ();

            //for every lock on mark they have, create a projectile and direct it towards them
            for (int i = 0; i < l.lockedOn; i++)
            {
                GameObject thisProjectile = Instantiate(homingProjectile, gameObject.transform.position + Random.insideUnitSphere, Quaternion.identity);
                homingProjectileTarget        = thisProjectile.GetComponent <HomingAttack> ();
                homingProjectileTarget.target = c.gameObject;
            }
            //clear their marks
            l.lockedOn = 0;
        }
        //two failsafes that reset the variables and hide the UI elements regarding lock on weapon
        if (lockOnCount > 0)
        {
            lockOnCount           = 0;
            lockonCounter.text    = lockOnCount.ToString();
            lockonCounter.enabled = false;
            return(true);
        }
        else
        {
            lockOnCount           = 0;
            lockonCounter.text    = lockOnCount.ToString();
            lockonCounter.enabled = false;
            return(false);
        }
    }
コード例 #9
0
 public void SetLockOn(LockOnTarget target)
 {
     this.lockOnTarget = target;
 }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     LockTargetScript = GameObject.Find("Main Camera Main1").GetComponent <LockOnTarget> ();
 }
コード例 #11
0
ファイル: CameraController.cs プロジェクト: ishikawaFm/sose
 void Start()
 {
     mainCamre    = Camera.main.gameObject;
     player       = GameObject.FindGameObjectWithTag("player");
     lockOnTarget = player.GetComponentInChildren <LockOnTarget>();
 }
コード例 #12
0
 // Start is called before the first frame update
 void Start()
 {
     m_lockOn = gameObject.GetComponent <LockOnTarget>();
 }