コード例 #1
0
 private static void ClearList(List <AudioClip> target)
 {
     while (STDLCMethods.FindInList(null, target))
     {
         target.Remove(null);
     }
 }
コード例 #2
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (Input.GetMouseButtonDown(1))
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 1000))
         {
             if (STDLCMethods.FindInList(gameObject, _GDB.selectList) & !_st.AI & !_st.FreandAI)
             {
                 BuilderTarget = hit.transform.gameObject;
             }
         }
     }
 }
コード例 #3
0
    void OnDestroy()
    {
        if (_st.AI || _st.FreandAI)
        {
            if (_st.Owner != null)
            {
                if (STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().Builders))
                {
                    _st.Owner.GetComponent <GlobalAI>().Builders.Remove(gameObject);
                }

                if (BuilderTarget == null)
                {
                    if (STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().FreeBuilders))
                    {
                        _st.Owner.GetComponent <GlobalAI>().FreeBuilders.Remove(gameObject);
                    }
                }
            }
        }
    }
コード例 #4
0
 public void Fix()
 {
     if (curShipYard == null)
     {
         FixModule _nfx = NearestShipYard().GetComponent <FixModule>();
         curShipYard = _nfx.gameObject;
         if (!STDLCMethods.FindInList(gameObject, _nfx.ShipsToFix))
         {
             _nfx.ShipsToFix.Add(gameObject);
         }
         _agent.CurFleet.Clear();
         //_SEL.PlayFixSound(gameObject);
         ForcedFix = true;
     }
     else
     {
         ForcedFix     = false;
         curShipYard   = null;
         _st.StopOrder = true;
     }
 }
コード例 #5
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (STDLCMethods.FindInList(gameObject, _GDB.selectList))
     {
         WasSelect = true;
         isSelect  = true;
         if (Proector.activeSelf == false)
         {
             Proector.SetActive(true);
         }
     }
     else
     {
         WasSelect = false;
         isSelect  = false;
         Proector.SetActive(false);
         if (BoxSelected)
         {
             BoxSelected = false;
         }
     }
 }
コード例 #6
0
 void FindAndAddShips()
 {
     if (_GDB.selectList.Count > 0)
     {
         foreach (GameObject obj in _GDB.selectList)
         {
             HealthModule _SHM = obj.GetComponent <HealthModule>();
             if (!_SHM._st.AI && !_SHM._st.FreandAI && !_SHM._st.Neutral && !_SHM._st.NeutralAgrass)
             {
                 if (_SHM.curHealth < _SHM.maxHealth || _SHM.curImpulseSystemHealth < _SHM.maxImpulseSystemHealth || _SHM.curLifeSupportSystemHealth < _SHM.maxLifeSupportSystemHealth || _SHM.curPrimaryWeaponSystemHealth < _SHM.maxPrimaryWeaponSystemHealth || _SHM.curTractorBeamSystemHealth < _SHM.maxTractorBeamSystemHealth || _SHM.curWarpEngingSystemHealth < _SHM.maxWarpEngingSystemHealth || _SHM.curWarpCoreHealth < _SHM.maxWarpCoreHealth || _SHM.curSecondaryWeaponSystemHealth < _SHM.maxSecondaryWeaponSystemHealth || _SHM.curCrew < _SHM.maxCrew || _SHM.CurShilds < _SHM.Shilds)
                 {
                     if (!STDLCMethods.FindInList(obj, ShipsToFix))
                     {
                         ShipsToFix.Add(obj);
                     }
                     obj.GetComponent <MoveComponent>().CurFleet.Clear();
                     obj.GetComponent <ActiveState>().curShipYard = gameObject;
                     _SEL.PlayUnitSound(gameObject, "Fix");
                 }
             }
         }
     }
 }
コード例 #7
0
    // Update is called once per frame
    void Update()
    {
        if (BuildFroze)
        {
            if (FixTarget != null)
            {
                BuildModule.Fixing = true;
            }
            else
            {
                BuildModule.Fixing = false;
            }
        }
        if (FixTarget != null)
        {
            if (FixTarget.GetComponent <Stats>().StopOrder)
            {
                if (R1)
                {
                    R1        = false;
                    Repair    = false;
                    FixTarget = null;
                }
                if (R2)
                {
                    R2 = false;
                    R3 = true;

                    EnteringProcess = 0;
                    MSPAccepted     = false;
                }
            }
            else
            {
                Repair = true;
                if (!R1 && !R2 && !R3)
                {
                    R1 = true;
                }
            }
        }
        else
        {
            R1     = false;
            R2     = false;
            R3     = false;
            Repair = false;

            EnteringProcess = 0;
            MSPAccepted     = false;
        }
        if (ShipsToFix.Count > 0)
        {
            CreateWaitingPoints();

            foreach (GameObject obj in ShipsToFix)
            {
                if (obj.GetComponent <Stats>().StopOrder)
                {
                    ShipsToFix.Remove(obj);
                    obj.GetComponent <ActiveState>().ForcedFix   = false;
                    obj.GetComponent <ActiveState>().curShipYard = null;
                }
            }
        }

        if (!_sb.AI && !_sb.FreandAI && !_sb.Neutral && !_sb.NeutralAgrass)
        {
            if (_sb.Hovering)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    FindAndAddShips();
                }
            }
        }

        if (Repair)
        {
            if (FixTarget != null)
            {
                MoveComponent _tmc = FixTarget.GetComponent <MoveComponent>();
                HealthModule  _SHM = FixTarget.GetComponent <HealthModule>();
                if (R1)
                {
                    if (Vector3.Distance(FixTarget.transform.position, RPoint1.transform.position) > (_SHM.ShipRadius / 1.5f) + (_tmc.ForwardSpeed * _tmc.ForwardSpeed / 2) / _tmc.MaxAcceleration)
                    {
                        _tmc.Movement(RPoint1.transform.position);
                        if (Vector3.Distance(_tmc.transform.position, RPoint1.transform.position) <= _SHM.ShipRadius)
                        {
                            Vector3 rpos = RPoint2.transform.position - _tmc.transform.position;

                            Quaternion rotation = Quaternion.LookRotation(rpos);

                            float Amount = 0;
                            if (Amount < 1)
                            {
                                Amount += Time.deltaTime / _tmc.RotationAcceleration;
                            }

                            _tmc.RotateShipAndMoveToTarget(rotation.eulerAngles, RPoint1.transform.position, Amount, true, true);
                        }
                    }
                    else
                    {
                        R2 = true;
                        R1 = false;
                    }
                    FixTarget.GetComponent <Stats>().IsFix = true;
                    if (R3)
                    {
                        R3 = false;
                    }
                }
                if (R2)
                {
                    gameObject.GetComponent <ShipBuild>().CurOpenTimer = 1;
                    if (Vector3.Distance(FixTarget.transform.position, RPoint2.transform.position) > 1)
                    {
                        FixTarget.GetComponent <Rigidbody>().isKinematic = true;

                        Vector3 LookVector = (RPoint2.transform.position - FixTarget.transform.position);
                        FixTarget.transform.rotation = Quaternion.Slerp(FixTarget.transform.rotation, Quaternion.LookRotation(LookVector), 0.03f);

                        Vector3 dirFromAtoB = (RPoint2.transform.position - FixTarget.transform.position).normalized;
                        float   dotProd     = Vector3.Dot(dirFromAtoB, FixTarget.transform.forward);

                        if (dotProd > 0.95)
                        {
                            if (!MSPAccepted)
                            {
                                MovementStart = FixTarget.transform.position;
                                MSPAccepted   = true;
                            }

                            if (EnteringProcess < 1)
                            {
                                EnteringProcess += Time.deltaTime * (1 / FixTarget.GetComponent <MoveComponent>().MovementSpeed *AnimationSpeed);
                            }
                            else
                            {
                                EnteringProcess = 1;
                            }

                            FixTarget.transform.position = Vector3.Lerp(MovementStart, RPoint2.transform.position, EnteringProcess);
                        }

                        gameObject.GetComponent <ShipBuild>().CurOpenTimer = 1;
                    }
                    if (Vector3.Distance(FixTarget.transform.position, RPoint2.transform.position) <= 1)
                    {
                        EnteringProcess = 0;
                        MSPAccepted     = false;

                        Vector3 LookVector = (FixTarget.transform.position - RPoint2.transform.position);
                        FixTarget.transform.rotation = Quaternion.Slerp(FixTarget.transform.rotation, Quaternion.LookRotation(LookVector), 0.03f);

                        if (_SHM.curHealth < _SHM.maxHealth)
                        {
                            if (_GDB.Titanium > 0)
                            {
                                _GDB.Titanium -= Time.deltaTime * 2;
                                if (_SHM.curHealth < _SHM.maxHealth)
                                {
                                    _SHM.curHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curHealth = _SHM.maxHealth;
                                }

                                if (_SHM.curImpulseSystemHealth < _SHM.maxImpulseSystemHealth)
                                {
                                    _SHM.curImpulseSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curImpulseSystemHealth = _SHM.maxImpulseSystemHealth;
                                }

                                if (_SHM.curLifeSupportSystemHealth < _SHM.maxLifeSupportSystemHealth)
                                {
                                    _SHM.curLifeSupportSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curLifeSupportSystemHealth = _SHM.maxLifeSupportSystemHealth;
                                }

                                if (_SHM.curPrimaryWeaponSystemHealth < _SHM.maxPrimaryWeaponSystemHealth)
                                {
                                    _SHM.curPrimaryWeaponSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curPrimaryWeaponSystemHealth = _SHM.maxPrimaryWeaponSystemHealth;
                                }

                                if (_SHM.curSensorsSystemHealth < _SHM.maxSensorsSystemHealth)
                                {
                                    _SHM.curSensorsSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curSensorsSystemHealth = _SHM.maxSensorsSystemHealth;
                                }

                                if (_SHM.curTractorBeamSystemHealth < _SHM.maxTractorBeamSystemHealth)
                                {
                                    _SHM.curTractorBeamSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curTractorBeamSystemHealth = _SHM.maxTractorBeamSystemHealth;
                                }

                                if (_SHM.curWarpEngingSystemHealth < _SHM.maxWarpEngingSystemHealth)
                                {
                                    _SHM.curWarpEngingSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curWarpEngingSystemHealth = _SHM.maxWarpEngingSystemHealth;
                                }

                                if (_SHM.curWarpCoreHealth < _SHM.maxWarpCoreHealth)
                                {
                                    _SHM.curWarpCoreHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curWarpCoreHealth = _SHM.maxWarpCoreHealth;
                                }

                                if (_SHM.curSecondaryWeaponSystemHealth < _SHM.maxSecondaryWeaponSystemHealth)
                                {
                                    _SHM.curSecondaryWeaponSystemHealth += Time.deltaTime * 2;
                                }
                                else
                                {
                                    _SHM.curSecondaryWeaponSystemHealth = _SHM.maxSecondaryWeaponSystemHealth;
                                }

                                if (_SHM.CurShilds < _SHM.Shilds)
                                {
                                    _SHM.CurShilds += Time.deltaTime * 20;
                                }
                                else
                                {
                                    _SHM.CurShilds = _SHM.Shilds;
                                }

                                if (_GDB.Humans > 0)
                                {
                                    if (_SHM.curCrew < _SHM.maxCrew)
                                    {
                                        _GDB.Humans  -= Time.deltaTime * 4;
                                        _SHM.curCrew += Time.deltaTime * 4;
                                    }
                                    else
                                    {
                                        _SHM.curCrew = _SHM.maxCrew;
                                    }
                                }

                                if (_SHM.curHealth >= _SHM.maxHealth && _SHM.curImpulseSystemHealth >= _SHM.maxImpulseSystemHealth && _SHM.curLifeSupportSystemHealth >= _SHM.maxLifeSupportSystemHealth && _SHM.curPrimaryWeaponSystemHealth >= _SHM.maxPrimaryWeaponSystemHealth && _SHM.curTractorBeamSystemHealth >= _SHM.maxTractorBeamSystemHealth && _SHM.curWarpEngingSystemHealth >= _SHM.maxWarpEngingSystemHealth && _SHM.curWarpCoreHealth >= _SHM.maxWarpCoreHealth && _SHM.curSecondaryWeaponSystemHealth >= _SHM.maxSecondaryWeaponSystemHealth && _SHM.curCrew >= _SHM.maxCrew && _SHM.CurShilds >= _SHM.Shilds)
                                {
                                    R3 = true;
                                    R2 = false;
                                }
                            }
                            else
                            {
                                R3 = true;
                                R2 = false;
                            }
                        }
                    }
                    FixTarget.GetComponent <Stats>().IsFix = true;
                }
                if (R3)
                {
                    if (Vector3.Distance(FixTarget.transform.position, RPoint3.transform.position) > 1)
                    {
                        Vector3 LookVector = (RPoint3.transform.position - FixTarget.transform.position);
                        FixTarget.transform.rotation = Quaternion.Slerp(FixTarget.transform.rotation, Quaternion.LookRotation(LookVector), 0.03f);

                        Vector3 dirFromAtoB = (RPoint3.transform.position - FixTarget.transform.position).normalized;
                        float   dotProd     = Vector3.Dot(dirFromAtoB, FixTarget.transform.forward);

                        if (dotProd > 0.95)
                        {
                            if (!MSPAccepted)
                            {
                                MovementStart = FixTarget.transform.position;
                                MSPAccepted   = true;
                            }

                            if (EnteringProcess < 1)
                            {
                                EnteringProcess += Time.deltaTime * (1 / FixTarget.GetComponent <MoveComponent>().MovementSpeed *AnimationSpeed);
                            }
                            else
                            {
                                EnteringProcess = 1;
                            }

                            FixTarget.transform.position = Vector3.Lerp(MovementStart, RPoint3.transform.position, EnteringProcess);
                        }

                        gameObject.GetComponent <ShipBuild>().CurOpenTimer = 1;
                    }
                    if (Vector3.Distance(FixTarget.transform.position, RPoint3.transform.position) <= 1)
                    {
                        EnteringProcess = 0;
                        MSPAccepted     = false;

                        FixTarget.GetComponent <Rigidbody>().isKinematic = false;

                        FixTarget.GetComponent <Stats>().SelectLock = false;
                        if (STDLCMethods.FindInList(FixTarget, ShipsToFix))
                        {
                            ShipsToFix.Remove(FixTarget);
                        }
                        FixTarget = null;
                        Repair    = false;
                        R3        = false;
                    }
                    FixTarget.GetComponent <Stats>().IsFix             = false;
                    FixTarget.GetComponent <ActiveState>().ForcedFix   = false;
                    FixTarget.GetComponent <ActiveState>().curShipYard = null;
                }
            }
            else
            {
                Repair = false;
            }
        }
    }
コード例 #8
0
    void Update()
    {
        if (Warp)
        {
            _agent.Warp = true;
        }
        else
        {
            _agent.Warp = false;
        }

        if (IsFix)
        {
            _agent.SensorBlocking = true;
        }
        else
        {
            _agent.SensorBlocking = false;
        }

        if (Neutral)
        {
            if (Owner != null)
            {
                gameObject.GetComponent <ShipAI>().ShipIsСaptured();
                Owner = null;
            }
        }

        if (Assimilated)
        {
            VoiceIndex _vi = gameObject.GetComponent <VoiceIndex>();
            _vi.race = VoiceIndex.enRace.Borg;
            _vi.initRace();
        }

        if (STDLCMethods.FindInList(gameObject, _GDB.selectList))
        {
            Proector.GetComponent <MeshRenderer>().enabled = true;
        }
        else
        {
            Proector.GetComponent <MeshRenderer>().enabled = false;
        }

        if (orderstoptimer > 0)
        {
            orderstoptimer -= Time.deltaTime;
        }
        else
        {
            StopOrder      = false;
            orderstoptimer = 0.5f;
        }

        if (AI || FreandAI)
        {
            gameObject.GetComponent <ShipAI>().enabled = true;
        }
        else
        {
            gameObject.GetComponent <ShipAI>().enabled = false;
        }

        if (targetTransform == gameObject.transform)
        {
            targetTransform = null;
        }

        if (!SelectLock)
        {
            if (TimerDown)
            {
                if (Timer > 0)
                {
                    Timer -= Time.deltaTime;
                }

                if (Timer <= 0)
                {
                    if (isSelect)
                    {
                        WasSelect = true;
                    }

                    Timer     = 0.1f;
                    TimerDown = false;
                }
            }

            if (Selected)
            {
                Camera.GetComponent <CameraRay>().Locker = false;
                //_select.Lock = false;
            }
            else
            {
                Camera.GetComponent <CameraRay>().Locker = true;
                //elect.Lock = true;
            }
        }
        else
        {
            //BoxSelected = false;
            //MeshLock = false;
        }

        if (AI)
        {
            gameObject.tag = "Enemy";
        }

        if (!AI)
        {
            if (FreandAI && !Neutral && !NeutralAgrass)
            {
                gameObject.tag = "Freand";
            }

            if (!FreandAI && !Neutral && !NeutralAgrass)
            {
                gameObject.tag = "Dwarf";
            }
        }

        if (Neutral)
        {
            gameObject.tag = "Neutral";
        }

        if (NeutralAgrass)
        {
            gameObject.tag = "NeutralAgrass";
        }

        if (_HP.curTractorBeamSystemHealth > 0)
        {
            if (!_AS.Tractor.GetComponent <Tractor>().Use)
            {
                if (_HP.maxCrew > 0)
                {
                    if (_HP.curImpulseSystemHealth > _HP.maxImpulseSystemHealth * 0.125f && !_HP.ActiveImpulse &&
                        _HP.curCrew > 0)
                    {
                        if (Vector3.Distance(gameObject.transform.position, targetVector) > 400)
                        {
                            if (_HP.curWarpEngingSystemHealth > _HP.maxWarpEngingSystemHealth * 0.125 &&
                                !_HP.ActiveWarpEnging && _HP.curWarpCoreHealth > _HP.maxWarpCoreHealth * 0.125 &&
                                !_HP.ActiveWarpCore)
                            {
                                if (!_agent.CUBETYPE)
                                {
                                    if (!_agent.ForwardBlocked &&
                                        Vector3.Distance(_agent.RightSensor.transform.position, _agent.TargetVector) <
                                        Vector3.Distance(_agent.LeftSensor.transform.position, _agent.TargetVector) +
                                        (0.1f * _agent.RotationSpeed) &&
                                        Vector3.Distance(_agent.LeftSensor.transform.position, _agent.TargetVector) <
                                        Vector3.Distance(_agent.RightSensor.transform.position, _agent.TargetVector) +
                                        (0.1f * _agent.RotationSpeed) &&
                                        Vector3.Distance(_agent.UpSensor.transform.position, _agent.TargetVector) <
                                        Vector3.Distance(_agent.DownSensor.transform.position, _agent.TargetVector) +
                                        (0.1f * _agent.RotationSpeed) &&
                                        Vector3.Distance(_agent.DownSensor.transform.position, _agent.TargetVector) <
                                        Vector3.Distance(_agent.UpSensor.transform.position, _agent.TargetVector) +
                                        (0.1f * _agent.RotationSpeed))
                                    {
                                        if (WarpEffectDelay > 0)
                                        {
                                            WarpEffect       = true;
                                            WarpEffectDelay -= Time.deltaTime;
                                        }
                                        else
                                        {
                                            Warp       = true;
                                            WarpEffect = false;
                                        }
                                    }
                                    else
                                    {
                                        Warp            = false;
                                        WarpEffect      = false;
                                        WarpEffectDelay = 0.5f;
                                    }
                                }
                                else
                                {
                                    if (WarpEffectDelay > 0)
                                    {
                                        WarpEffect       = true;
                                        WarpEffectDelay -= Time.deltaTime;
                                    }
                                    else
                                    {
                                        Warp       = true;
                                        WarpEffect = false;
                                    }
                                }
                            }
                            else
                            {
                                if (Warp)
                                {
                                    Warp            = false;
                                    WarpEffect      = false;
                                    WarpEffectDelay = 0.5f;
                                }
                            }
                        }

                        if (Vector3.Distance(gameObject.transform.position, targetVector) <= 200)
                        {
                            if (Warp)
                            {
                                Warp            = false;
                                WarpEffect      = false;
                                WarpEffectDelay = 0.5f;
                            }
                        }
                    }
                    else
                    {
                        Warp            = false;
                        WarpEffect      = false;
                        WarpEffectDelay = 0.5f;
                        _agent.Warp     = false;
                    }
                }
                else
                {
                    if (_HP.curImpulseSystemHealth > _HP.maxImpulseSystemHealth * 0.125f && !_HP.ActiveImpulse)
                    {
                        if (Vector3.Distance(gameObject.transform.position, targetVector) > 400)
                        {
                            if (_HP.curWarpEngingSystemHealth > _HP.maxWarpEngingSystemHealth * 0.125 ||
                                !_HP.ActiveWarpEnging)
                            {
                                Warp = true;
                            }
                            else
                            {
                                if (Warp)
                                {
                                    Warp = false;
                                }
                            }
                        }

                        if (Vector3.Distance(gameObject.transform.position, targetVector) <= 200)
                        {
                            if (Warp)
                            {
                                Warp = false;
                            }
                        }
                    }
                    else
                    {
                        Warp = false;
                    }
                }
            }
        }
        else
        {
            if (_HP.maxCrew > 0)
            {
                if (_HP.curImpulseSystemHealth > _HP.maxImpulseSystemHealth * 0.125f && !_HP.ActiveImpulse &&
                    _HP.curCrew > 0)
                {
                    if (Vector3.Distance(gameObject.transform.position, targetVector) > 400)
                    {
                        if (_HP.curWarpEngingSystemHealth > _HP.maxWarpEngingSystemHealth * 0.125 &&
                            !_HP.ActiveWarpEnging && _HP.curWarpCoreHealth > _HP.maxWarpCoreHealth * 0.125 &&
                            !_HP.ActiveWarpCore)
                        {
                            if (!_agent.CUBETYPE)
                            {
                                if (!_agent.ForwardBlocked &&
                                    Vector3.Distance(_agent.RightSensor.transform.position, _agent.TargetVector) <
                                    Vector3.Distance(_agent.LeftSensor.transform.position, _agent.TargetVector) +
                                    (0.1f * _agent.RotationSpeed) &&
                                    Vector3.Distance(_agent.LeftSensor.transform.position, _agent.TargetVector) <
                                    Vector3.Distance(_agent.RightSensor.transform.position, _agent.TargetVector) +
                                    (0.1f * _agent.RotationSpeed) &&
                                    Vector3.Distance(_agent.UpSensor.transform.position, _agent.TargetVector) <
                                    Vector3.Distance(_agent.DownSensor.transform.position, _agent.TargetVector) +
                                    (0.1f * _agent.RotationSpeed) &&
                                    Vector3.Distance(_agent.DownSensor.transform.position, _agent.TargetVector) <
                                    Vector3.Distance(_agent.UpSensor.transform.position, _agent.TargetVector) +
                                    (0.1f * _agent.RotationSpeed))
                                {
                                    if (WarpEffectDelay > 0)
                                    {
                                        WarpEffect       = true;
                                        WarpEffectDelay -= Time.deltaTime;
                                    }
                                    else
                                    {
                                        Warp       = true;
                                        WarpEffect = false;
                                    }
                                }
                                else
                                {
                                    Warp            = false;
                                    WarpEffect      = false;
                                    WarpEffectDelay = 0.5f;
                                }
                            }
                            else
                            {
                                if (WarpEffectDelay > 0)
                                {
                                    WarpEffect       = true;
                                    WarpEffectDelay -= Time.deltaTime;
                                }
                                else
                                {
                                    Warp       = true;
                                    WarpEffect = false;
                                }
                            }
                        }
                        else
                        {
                            if (Warp)
                            {
                                Warp            = false;
                                WarpEffect      = false;
                                WarpEffectDelay = 0.5f;
                            }
                        }
                    }

                    if (Vector3.Distance(gameObject.transform.position, targetVector) <= 200)
                    {
                        if (Warp)
                        {
                            Warp            = false;
                            WarpEffect      = false;
                            WarpEffectDelay = 0.5f;
                        }
                    }
                }
                else
                {
                    Warp            = false;
                    WarpEffect      = false;
                    WarpEffectDelay = 0.5f;
                }
            }
            else
            {
                if (_HP.curImpulseSystemHealth > _HP.maxImpulseSystemHealth * 0.125f && !_HP.ActiveImpulse)
                {
                    if (Vector3.Distance(gameObject.transform.position, targetVector) > 400)
                    {
                        if (_HP.curWarpEngingSystemHealth > _HP.maxWarpEngingSystemHealth * 0.125 ||
                            !_HP.ActiveWarpEnging)
                        {
                            Warp = true;
                        }
                        else
                        {
                            if (Warp)
                            {
                                Warp = false;
                            }
                        }
                    }

                    if (Vector3.Distance(gameObject.transform.position, targetVector) <= 200)
                    {
                        if (Warp)
                        {
                            Warp = false;
                        }
                    }
                }
                else
                {
                    Warp = false;
                    //	gameObject.GetComponent<Rigidbody>().velocity = gameObject.transform.forward * _agent.MovementSpeed;
                }
            }
        }

        if (!isSelect)
        {
            AttackStations  = false;
            DefenceStations = false;
            NatralStations  = false;
        }

        if (Name == System.String.Empty)
        {
            InitName();
        }

        SensorsLine.transform.position = gameObject.transform.position;
        _scr.radius = _es.VisionRadius;

        WeaponLine.transform.position = gameObject.transform.position;
        _wcr.radius = _AS.radiuse;
    }
コード例 #9
0
    void Update()
    {
        if (BuilderTarget != null)
        {
            DistanceToBuilding = Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position);
            if (!_st.AI & !_st.FreandAI)
            {
                if (BuilderTarget.tag == "BuildingBuilding")
                {
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) > BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        Build = false;
                        _agent.Movement(BuilderTarget.transform.position);
                    }
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) <= BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        if (!StopBool)
                        {
                            gameObject.GetComponent <Stats> ().targetVector = gameObject.transform.position;
                            _agent.Stop();
                            //_agent.ResetPath ();
                            StopBool = true;
                        }
                        Build = true;
                    }
                }
                if (BuilderTarget.tag != "BuildingBuilding")
                {
                    Build         = false;
                    BuilderTarget = null;
                }
            }
            if (_st.AI)
            {
                if (BuilderTarget.tag == "BuildingBuildingEnemy")
                {
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) > BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        Build = false;
                        _agent.Movement(BuilderTarget.transform.position);
                    }
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) <= BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        Build = true;
                        if (!StopBool)
                        {
                            gameObject.GetComponent <Stats> ().targetVector = gameObject.transform.position;
                            _agent.Stop();
                            //_agent.ResetPath ();
                            StopBool = true;
                        }
                    }
                }
                if (BuilderTarget.tag != "BuildingBuildingEnemy")
                {
                    Build         = false;
                    BuilderTarget = null;
                }
            }
            if (_st.FreandAI)
            {
                if (BuilderTarget.tag == "BuildingBuildingFreand")
                {
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) > BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        Build = false;
                        _agent.Movement(BuilderTarget.transform.position);
                    }
                    if (Vector3.Distance(gameObject.transform.position, BuilderTarget.transform.position) <= BuilderTarget.GetComponent <BuildingStationScript> ().BuildDistance)
                    {
                        Build = true;
                        if (!StopBool)
                        {
                            gameObject.GetComponent <Stats> ().targetVector = gameObject.transform.position;
                            _agent.Stop();
                            //_agent.ResetPath ();
                            StopBool = true;
                        }
                    }
                }
                if (BuilderTarget.tag != "BuildingBuildingFreand")
                {
                    Build         = false;
                    BuilderTarget = null;
                }
            }
        }
        if (Build)
        {
            if (BuilderTarget != null)
            {
                if (!STDLCMethods.FindInList(gameObject, BuilderTarget.GetComponent <BuildingStationScript>().Builders))
                {
                    BuilderTarget.GetComponent <BuildingStationScript> ().Builders.Add(gameObject);
                    _GDB.gameObject.GetComponent <Select> ().PlayComputerSound(_GDB.PlayerRace, "stationConstructingBegan");
                }
                if (_st.WasSelect)
                {
                    if (!_st.AI & !_st.FreandAI)
                    {
                        if (Input.GetMouseButtonDown(1))
                        {
                            BuilderTarget.GetComponent <BuildingStationScript> ().Builders.Remove(gameObject);
                            //BuilderTarget = null;
                            Build = false;
                        }
                    }
                }
            }
        }
        if (BuilderTarget != null & !Build)
        {
            BuilderTarget.GetComponent <BuildingStationScript> ().Builders.Remove(gameObject);
        }
        if (BuilderTarget != null)
        {
            if (BuilderTarget.GetComponent <BuildingStationScript> ().Timer <= 0)
            {
                StopBool = false;
            }
        }
        if (!Build)
        {
            StopBool = false;
        }
        if (BuilderTarget == null)
        {
            Build = false;
        }
        if (BuilderTarget != null)
        {
            if (_st.AI || _st.FreandAI)
            {
                BuilderTarget.GetComponent <BuildingStationScript> ().Owner = _st.Owner;
            }
            if (BuilderTarget.GetComponent <BuildingStationScript> ().Timer <= 0)
            {
                if (!BuilderTarget.GetComponent <BuildingStationScript> ().AI&& !BuilderTarget.GetComponent <BuildingStationScript> ().FreandAI)
                {
                    _GDB.gameObject.GetComponent <Select>().PlayComputerSound(_GDB.PlayerRace, "stationConstructingEnd");
                }
            }
        }
        if (_st.AI || _st.FreandAI)
        {
            if (_st.Owner != null)
            {
                if (!gameObject.GetComponent <ShipAI>().DilithiumMiner&& !gameObject.GetComponent <ShipAI>().TitaniumMiner)
                {
                    if (!STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().Builders))
                    {
                        _st.Owner.GetComponent <GlobalAI>().Builders.Add(gameObject);
                    }

                    if (BuilderTarget == null)
                    {
                        if (!STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().FreeBuilders))
                        {
                            _st.Owner.GetComponent <GlobalAI>().FreeBuilders.Add(gameObject);
                        }
                    }
                    else
                    {
                        if (STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().FreeBuilders))
                        {
                            _st.Owner.GetComponent <GlobalAI>().FreeBuilders.Remove(gameObject);
                        }
                    }
                }
                else
                {
                    if (STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().Builders))
                    {
                        _st.Owner.GetComponent <GlobalAI>().Builders.Remove(gameObject);
                    }

                    if (STDLCMethods.FindInList(gameObject, _st.Owner.GetComponent <GlobalAI>().FreeBuilders))
                    {
                        _st.Owner.GetComponent <GlobalAI>().FreeBuilders.Remove(gameObject);
                    }
                }
            }
        }
    }
コード例 #10
0
    private void ResetTeams(GameObject obj, GameObject obj1, int ClickNum)
    {
        if (_GDB.selectList.Count > 0 && _GDB.activeObjectInterface == null)
        {
            switch (ClickNum)
            {
            case 1:
                Num1 = _GDB.selectList.ToList();
                break;

            case 2:
                Num2 = _GDB.selectList.ToList();
                break;

            case 3:
                Num3 = _GDB.selectList.ToList();
                break;

            case 4:
                Num4 = _GDB.selectList.ToList();
                break;

            case 5:
                Num5 = _GDB.selectList.ToList();
                break;

            case 6:
                Num6 = _GDB.selectList.ToList();
                break;

            case 7:
                Num7 = _GDB.selectList.ToList();
                break;

            case 8:
                Num8 = _GDB.selectList.ToList();
                break;

            case 9:
                Num9 = _GDB.selectList.ToList();
                break;

            case 0:
                Num0 = _GDB.selectList.ToList();
                break;
            }

            if (ClickNum != 1)
            {
                if (STDLCMethods.FindInList(obj, Num1))
                {
                    Num1.Remove(obj);
                }
            }

            if (ClickNum != 2)
            {
                if (STDLCMethods.FindInList(obj, Num2))
                {
                    Num2.Remove(obj);
                }
            }

            if (ClickNum != 3)
            {
                if (STDLCMethods.FindInList(obj, Num3))
                {
                    Num3.Remove(obj);
                }
            }

            if (ClickNum != 4)
            {
                if (STDLCMethods.FindInList(obj, Num4))
                {
                    Num4.Remove(obj);
                }
            }

            if (ClickNum != 5)
            {
                if (STDLCMethods.FindInList(obj, Num5))
                {
                    Num5.Remove(obj);
                }
            }

            if (ClickNum != 6)
            {
                if (STDLCMethods.FindInList(obj, Num6))
                {
                    Num6.Remove(obj);
                }
            }

            if (ClickNum != 7)
            {
                if (STDLCMethods.FindInList(obj, Num7))
                {
                    Num7.Remove(obj);
                }
            }

            if (ClickNum != 8)
            {
                if (STDLCMethods.FindInList(obj, Num8))
                {
                    Num8.Remove(obj);
                }
            }

            if (ClickNum != 9)
            {
                if (STDLCMethods.FindInList(obj, Num9))
                {
                    Num9.Remove(obj);
                }
            }

            if (ClickNum != 0)
            {
                if (STDLCMethods.FindInList(obj, Num0))
                {
                    Num0.Remove(obj);
                }
            }

            obj1.GetComponent <HealthModule>().ResetTeam();
        }
        else if (_GDB.selectList.Count == 0 && _GDB.activeObjectInterface != null)
        {
            switch (ClickNum)
            {
            case 1:
                Num1.Clear();
                Num1.Add(_GDB.activeObjectInterface);
                break;

            case 2:
                Num2.Clear();
                Num2.Add(_GDB.activeObjectInterface);
                break;

            case 3:
                Num3.Clear();
                Num3.Add(_GDB.activeObjectInterface);
                break;

            case 4:
                Num4.Clear();
                Num4.Add(_GDB.activeObjectInterface);
                break;

            case 5:
                Num5.Clear();
                Num5.Add(_GDB.activeObjectInterface);
                break;

            case 6:
                Num6.Clear();
                Num6.Add(_GDB.activeObjectInterface);
                break;

            case 7:
                Num7.Clear();
                Num7.Add(_GDB.activeObjectInterface);
                break;

            case 8:
                Num8.Clear();
                Num8.Add(_GDB.activeObjectInterface);
                break;

            case 9:
                Num9.Clear();
                Num9.Add(_GDB.activeObjectInterface);
                break;

            case 0:
                Num0.Clear();
                Num0.Add(_GDB.activeObjectInterface);
                break;
            }
        }
    }
コード例 #11
0
    void Update()
    {
        if (VisibleObjectList.Count > 0)
        {
            List <GameObject> InvisibleShips = new List <GameObject>();
            foreach (GameObject obj in VisibleObjectList)
            {
                if (obj != null)
                {
                    if (Vector3.Distance(gameObject.transform.position, obj.transform.position) > (VisionRadius + 3 + obj.GetComponent <HealthModule>().ShipRadius))
                    {
                        if (IsShip)
                        {
                            if (!_st.AI && !_st.Neutral)
                            {
                                if (obj != gameObject)
                                {
                                    obj.GetComponent <ObjectTypeVisible>().IsVisible = false;
                                }
                            }
                        }
                        if (IsStation)
                        {
                            if (!_sb.AI && !_sb.Neutral)
                            {
                                if (obj != gameObject)
                                {
                                    obj.GetComponent <ObjectTypeVisible>().IsVisible = false;
                                }
                            }
                        }
                        InvisibleShips.Add(obj);
                    }
                }
                else
                {
                    InvisibleShips.Add(obj);
                }
            }
            foreach (GameObject obj in InvisibleShips)
            {
                VisibleObjectList.Remove(obj);
            }
            InvisibleShips.Clear();
        }

        List <Collider> colls = Physics.OverlapSphere(transform.position, VisionRadius).ToList();

        foreach (Collider C in colls)
        {
            if (C != null)
            {
                if (C.GetComponent <HealthModule>())
                {
                    if (VisibleObjectList.Count != 0)
                    {
                        if (!STDLCMethods.FindInList(C.gameObject, VisibleObjectList))
                        {
                            VisibleObjectList.Add(C.gameObject);
                        }
                    }
                    else
                    {
                        VisibleObjectList.Add(C.gameObject);
                    }


                    HealthModule CurScanTarget = C.GetComponent <HealthModule>();

                    if (IsShip)
                    {
                        if (!_st.AI && !_st.Neutral)
                        {
                            if (C.GetComponent <ObjectTypeVisible>())
                            {
                                C.GetComponent <ObjectTypeVisible>().IsVisible = true;
                            }
                            if (!CurScanTarget.Ship)
                            {
                                C.GetComponent <ObjectTypeVisible>().FirstFinded = true;
                            }
                        }

                        if (!_st.AI && !_st.Neutral)
                        {
                            if (CurScanTarget.tag == "Enemy")
                            {
                                Target = C.gameObject;
                            }
                        }
                        if (_st.AI)
                        {
                            if (CurScanTarget.tag == "Dwarf" || CurScanTarget.tag == "Freand")
                            {
                                Target = C.gameObject;
                            }
                        }
                    }
                    if (IsStation)
                    {
                        if (!_sb.AI && !_sb.Neutral)
                        {
                            if (C.GetComponent <ObjectTypeVisible>())
                            {
                                C.GetComponent <ObjectTypeVisible>().IsVisible = true;
                            }
                            if (!CurScanTarget.Ship)
                            {
                                C.GetComponent <ObjectTypeVisible>().FirstFinded = true;
                            }
                        }

                        if (!_sb.AI && !_sb.Neutral)
                        {
                            if (CurScanTarget.tag == "Enemy")
                            {
                                Target = C.gameObject;
                            }
                        }
                        if (_sb.AI)
                        {
                            if (CurScanTarget.tag == "Dwarf" || CurScanTarget.tag == "Freand")
                            {
                                Target = C.gameObject;
                            }
                        }
                    }
                }
            }
        }
    }