Basic class for monkeys and drones
Inheritance: MonoBehaviour
示例#1
0
        public static void NightModeThread()
        {
            while (true)
            {
                if (!Globals.NightModeEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                CBaseEntity           tonemapBaseEnt    = GlobalLists.entityList[CBasePlayer.TonemapControllerIndex];
                CEnvTonemapController tonemapController = tonemapBaseEnt == null ? null : new CEnvTonemapController(tonemapBaseEnt);
                if (tonemapController == null)
                {
                    continue;
                }

                //Implement Later On

                Thread.Sleep(Globals.UsageDelay);
            }
        }
示例#2
0
        public static void RadarThread()
        {
            while (true)
            {
                if (!Globals.RadarEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                int mp = EngineDLL.MaxPlayer;
                for (int i = 0; i < mp; i++)
                {
                    CBaseEntity baseEntity = entityList[i];
                    if (baseEntity == null)
                    {
                        continue;
                    }
                    CCSPlayer entity = new CCSPlayer(baseEntity);
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.Dormant)
                    {
                        continue;
                    }
                    if (entity.Team == CBasePlayer.Team)
                    {
                        continue;
                    }

                    if (!entity.Spotted)
                    {
                        entity.Spotted = true;
                    }
                }

                Thread.Sleep(Globals.UsageDelay);
            }
        }
示例#3
0
        public static void RenderColorThread()
        {
            while (true)
            {
                if (!Globals.RenderEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                int mp = EngineDLL.MaxPlayer;
                for (int i = 0; i < mp; i++)
                {
                    CBaseEntity baseEntity = entityList[i];
                    if (baseEntity == null)
                    {
                        continue;
                    }
                    CCSPlayer entity = new CCSPlayer(baseEntity);
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.Dormant)
                    {
                        continue;
                    }
                    if (entity.Health <= 0)
                    {
                        continue;
                    }

                    if (entity.Team != CBasePlayer.Team)
                    {
                        RenderColor rco = new RenderColor();
                        rco.r = Globals.RenderColor.R;
                        rco.g = Globals.RenderColor.G;
                        rco.b = Globals.RenderColor.B;
                        rco.a = 255;
                        entity.RenderColor = rco;
                    }

                    if (Globals.RenderEnemyOnly)
                    {
                        continue;
                    }

                    RenderColor rc = new RenderColor();
                    rc.r = Globals.RenderColor.R;
                    rc.g = Globals.RenderColor.G;
                    rc.b = Globals.RenderColor.B;
                    rc.a = 255;
                    entity.RenderColor = rc;
                }

                Thread.Sleep(Globals.UsageDelay);
            }
        }
示例#4
0
        public static void WallHackThread()
        {
            while (true)
            {
                if (!Globals.WallHackEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                int mp = EngineDLL.MaxPlayer;
                for (int i = 0; i < mp; i++)
                {
                    CBaseEntity baseEntity = entityList[i];
                    if (baseEntity == null)
                    {
                        continue;
                    }
                    CCSPlayer entity = new CCSPlayer(baseEntity);
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.Dormant)
                    {
                        continue;
                    }
                    if (entity.Health <= 0)
                    {
                        continue;
                    }

                    if (entity.Team != CBasePlayer.Team)
                    {
                        GlowObject glowObject = entityList[i].GlowObject;
                        glowObject.r                       = Globals.WallHackEnemy.R / 255;
                        glowObject.g                       = Globals.WallHackEnemy.G / 255;
                        glowObject.b                       = Globals.WallHackEnemy.B / 255;
                        glowObject.a                       = 0.7f;
                        glowObject.m_bFullBloom            = Globals.WallHackFullEnabled;
                        glowObject.m_nGlowStyle            = Globals.WallHackGlowOnly ? 1 : 0;
                        glowObject.m_bRenderWhenOccluded   = true;
                        glowObject.m_bRenderWhenUnoccluded = false;

                        entityList[i].GlowObject = glowObject;
                    }
                    else
                    {
                        GlowObject glowObject = entityList[i].GlowObject;
                        glowObject.r                       = 0 / 255;
                        glowObject.g                       = 255 / 255;
                        glowObject.b                       = 0 / 255;
                        glowObject.a                       = 0.7f;
                        glowObject.m_bFullBloom            = Globals.WallHackFullEnabled;
                        glowObject.m_nGlowStyle            = Globals.WallHackGlowOnly ? 1 : 0;
                        glowObject.m_bRenderWhenOccluded   = true;
                        glowObject.m_bRenderWhenUnoccluded = false;

                        entityList[i].GlowObject = glowObject;
                    }
                }

                Thread.Sleep(Globals.UsageDelay);
            }
        }
示例#5
0
    void Patrulha()
    {
        pulseTime -= Time.deltaTime;

        if(pulseTime < 0){
         scannedColliders = Physics.OverlapSphere(myTransform.position,16,enemyMask);//
           if(scannedColliders.Length > 0)
         enemyAround = true;
           else enemyAround = false;
          pulseTime = 2.0f;
        }

        if(enemyAround){

          // Fase de teste
          if(scannedColliders.Length > 1){
        float tempdistance = Mathf.Infinity;
        for(int i = 0; i < scannedColliders.Length; i ++ ){
          if(!scannedColliders[i]){
            Debug.LogWarning("Scanned colliders are empty somehow");
            return;
          }
          target = scannedColliders[i].transform;
          targetEntity = target.GetComponent<CBaseEntity>();
          Debug.Log("targetEntity: " + targetEntity);
          if(!targetEntity) return;
          if(targetEntity.Type == CBaseEntity.eObjType.Building) continue;
          float tempdistanceindex = Vector3.Distance(myTransform.position,target.position);
          if(tempdistanceindex < tempdistance){
            tempdistance = tempdistanceindex;
            break;
          }else{
            target = scannedColliders[0].transform;
            targetEntity = target.GetComponent<CBaseEntity>();
          }
        }

          }else{
        target = scannedColliders[0].transform;
        targetEntity = target.GetComponent<CBaseEntity>();
          }

          targetVector = target.position - myTransform.position;

           if(Vector3.Distance(myTransform.position,target.position) < detectionDistance
          && Vector3.Angle(targetVector,myTransform.forward) < detectionRadius){
        if(targetEntity.Type == CBaseEntity.eObjType.Building) return;
          pulseTime = 2.0f;
          status = eAlertLevel.DETECT;
          Debug.LogWarning("Angle enemy is found: " + Vector3.Angle(targetVector,myTransform.forward));
          existingAlert = GameObject.Instantiate(detectAlert,new Vector3(target.position.x,target.position.y + 15, target.position.z), Quaternion.identity) as GameObject;
           }else if(Vector3.Distance(myTransform.position,target.position) < detectionDistance
                && Vector3.Angle(targetVector,myTransform.forward) < alertRadius){
          status = eAlertLevel.ALERT;
           }

        }else{
          target = null;
        }

        Debug.DrawRay(myTransform.position,myTransform.forward * 10);
    }
示例#6
0
 /*
  * ===========================================================================================================
  * MENU ENABLING METHODS
  * ===========================================================================================================
  */
 /// <summary>
 /// Changes the menu type to show the player info
 /// </summary>
 /// <param name="caller"> The CBaseEntity component of the caller of this method </param>
 public void PlayerInfoMenuEnable(CBaseEntity caller)
 {
     menuType = eMenuType.PlayerInfo;
     this.caller = caller;
 }
示例#7
0
 /// <summary>
 /// Enables the patrol route selection menu.
 /// </summary>
 /// <param name='caller'>
 /// Caller.
 /// </param>
 public void PatrolDroneMenuEnable(CBaseEntity caller)
 {
     menuType = eMenuType.PatrolDrone;
     this.caller = caller;
 }
示例#8
0
    /// <summary>
    /// What happens when we hit something
    /// </summary>
    public virtual void Hit(Transform entityHit, Vector3 v3Position)
    {
        if (!trShooter)
        {
            return;
        }

        // Ignore entities shooting themselves
        if (trShooter.gameObject.layer == entityHit.gameObject.layer)
        {
            return;
        }

        // Enemy hitting one of our buildings
        if (entityHit.gameObject.layer == ShooterControl.buildingLayer &&
            trShooter.gameObject.layer == ShooterControl.enemyLayer)
        {
            // Get the building basic component
            CBaseEntity entityScript = entityHit.GetComponent <CBaseEntity>();

            if (entityScript)
            {
                entityScript.TakeDamage(fDamageDone, v3Position);
            }
            else
            {
                // DEBUG
                Debug.LogError(this.transform + " Missing CBaseEntity in " + entityHit);
            }
        }
        else if (entityHit.gameObject.layer == ShooterControl.enemyLayer &&
                 trShooter.gameObject.layer == ShooterControl.playerLayer)
        {
            CEnemy enemyScript = null;
            // FIXME
            // The enemy shield is filtered by the game object tag
            if (entityHit.gameObject.tag == "Shield")
            {
                // Our projectile hit the enemy shield, so we get the script from the "grandparent" :P
                enemyScript = entityHit.transform.parent.transform.parent.gameObject.GetComponent <CEnemy>();

                if (enemyScript.myColor == myColor)
                {
                    // Same color? The shot pass through the shield
                    return;
                }
            }
            else
            {
                // Our projectile hit an enemy
                enemyScript = entityHit.transform.parent.gameObject.GetComponent <CEnemy>();
                enemyScript.HitBy(myColor, fDamageDone);
            }
        }
        else
        {
            return;
        }

        // Destroy itself
        Die();
    }
示例#9
0
        public static void AimbotThread()
        {
            while (true)
            {
                if (!Globals.AimEnabled)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                int       mp               = EngineDLL.MaxPlayer;
                Rectangle screen           = Objects.Structs.Misc.GetWindowRect();
                Vector2   screenOrigin     = new Vector2(screen.Width / 2, screen.Height / 2);
                double    latestDistance   = screen.Width;
                Vector3   closestEntityPos = new Vector3(99999f, 0f, 0f);
                for (int i = 0; i < mp; i++)
                {
                    CBaseEntity baseEntity = entityList[i];
                    if (baseEntity == null)
                    {
                        continue;
                    }
                    CCSPlayer entity = new CCSPlayer(baseEntity);
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.Dormant)
                    {
                        continue;
                    }
                    if (entity.Health <= 0)
                    {
                        continue;
                    }
                    if (entity.Team == CBasePlayer.Team)
                    {
                        continue;
                    }

                    Vector3 entSelectedPos = entity.GetBonePosition((int)Globals.AimPosition);
                    Vector2 entPosOnScreen;
                    if (entSelectedPos.PointOnScreen(out entPosOnScreen))
                    {
                        if (entPosOnScreen.x > screen.Width || entPosOnScreen.x < 0 || entPosOnScreen.y > screen.Height || entPosOnScreen.y < 0)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }

                    double dist = Sqrt(Pow(screenOrigin.x - entPosOnScreen.x, 2) + Pow(screenOrigin.y - entPosOnScreen.y, 2));
                    if (dist < latestDistance)
                    {
                        latestDistance   = dist;
                        closestEntityPos = entSelectedPos;
                    }
                }

                if (closestEntityPos.x != 99999f && (GetAsyncKeyState(Globals.TriggerKey) & 0x8000) > 0)
                {
                    Angle AimAt = CalcAngle(CBasePlayer.VectorEyeLevel, closestEntityPos);

                    if (Globals.AimRecoil)
                    {
                        Angle Punch = CBasePlayer.ViewPunchAngle * 2.0f;
                        AimAt.x -= Punch.x;
                        AimAt.y -= Punch.y;
                    }

                    CBasePlayer.ViewAngle = AimAt;

                    if (!Globals.AimShootOnCollide)
                    {
                        if (weaponList.ActiveWeapon.IsSniper())
                        {
                            ClientDLL.ForceRightAttack(true);
                            Thread.Sleep(2);
                            ClientDLL.ForceAttack(true);
                            Thread.Sleep(5);
                            ClientDLL.ForceRightAttack(false);
                            ClientDLL.ForceAttack(false);
                        }
                        else
                        {
                            Thread.Sleep(1);
                            ClientDLL.ForceAttack(true);
                            Thread.Sleep(5);
                            ClientDLL.ForceAttack(false);
                        }
                    }
                }

                Thread.Sleep(Globals.UsageDelay);
            }
        }
示例#10
0
        public static void TriggerThread()
        {
            while (true)
            {
                if (!Globals.TriggerEnabled && !Globals.AimShootOnCollide)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }
                if (!EngineDLL.InGame)
                {
                    Thread.Sleep(Globals.IdleWait);
                    continue;
                }

                if (Globals.TriggerPressOnlyEnabled && !Globals.AimShootOnCollide)
                {
                    if ((GetAsyncKeyState(Globals.TriggerKey) & 0x8000) > 0)
                    {
                        if (CBasePlayer.CrosshairID > 0 && CBasePlayer.CrosshairID < EngineDLL.MaxPlayer + 2)
                        {
                            CBaseEntity baseEntity = entityList[CBasePlayer.CrosshairID - 1];
                            if (baseEntity == null)
                            {
                                continue;
                            }
                            CCSPlayer crossEntity = new CCSPlayer(baseEntity);
                            if (crossEntity == null)
                            {
                                continue;                      // TRIGGER BOT CRASH FIX
                            }
                            if (crossEntity != null && crossEntity.Team != CBasePlayer.Team)
                            {
                                Thread.Sleep(1);
                                ClientDLL.ForceAttack(true);
                                Thread.Sleep(5);
                                ClientDLL.ForceAttack(false);
                            }
                        }
                    }
                }
                else
                {
                    if (CBasePlayer.CrosshairID > 0 && CBasePlayer.CrosshairID < EngineDLL.MaxPlayer + 2)
                    {
                        CBaseEntity baseEntity = entityList[CBasePlayer.CrosshairID - 1];
                        if (baseEntity == null)
                        {
                            continue;
                        }
                        CCSPlayer crossEntity = new CCSPlayer(baseEntity);
                        if (crossEntity == null)
                        {
                            continue;
                        }
                        if (crossEntity != null && crossEntity.Team != CBasePlayer.Team)
                        {
                            Thread.Sleep(1);
                            ClientDLL.ForceAttack(true);
                            Thread.Sleep(5);
                            ClientDLL.ForceAttack(false);
                        }
                    }
                }

                Thread.Sleep(2);
            }
        }
示例#11
0
    /// <summary>
    /// Executes the delivery of the captured monkey to the prison building
    /// </summary>
    public void DeliverPrisoner(Transform tPrisonBuilding, CBaseEntity entityPrisoner)
    {
        if(entityPrisoner.Type == CBaseEntity.eObjType.Monkey) {

            // Cast CBaseEntity to CMonkey (it is actually a CMonkey instance, anyway)
            CMonkey monkeyEntity = entityPrisoner as CMonkey;
            monkeyEntity.ReleaseMe();

            // ... and immediately the building captures it
            CBuilding tBuildingClass = tPrisonBuilding.GetComponent<CBuilding>();
            tBuildingClass.ReceivePrisoner(monkeyEntity);
        }
    }
示例#12
0
    /// <summary>
    /// Release the captured object
    /// </summary>
    public virtual void ReleaseMe()
    {
        this.transform.parent = capturedFormerParent;

        // The capturer has lost us
        this.capturer.gameObject.GetComponent<CBaseEntity>().capturedEntity = null;
        this.capturer = null;

        // FIXME: find a better way to put the captured object back to the ground
        //Vector3 putMeBackInTheGround = new Vector3(transform.position.x, capturedFormerPosition.y,
        //		transform.position.z);

        //transform.position = putMeBackInTheGround;

        // Check if the object have a rigidbody attached
        if(this.rigidbody) {

            if(!this.rigidbody.useGravity) {

                // Turn off the gravity for this object
                this.rigidbody.useGravity = true;
            }
            if(this.rigidbody.isKinematic) {

                this.rigidbody.isKinematic = false;
            }
        }

        isCaptured = false;

        if(captureForceField)
            Destroy(captureForceField.gameObject);

        if(captureRay)
            Destroy(captureRay.gameObject);
    }
    /// <summary>
    /// Execute when the player presses the left mouse button
    /// Behaviours: select an unit, deselect-it if clicked in the terrain
    /// </summary>
    void CheckLeftMouseClick()
    {
        // Check if we're inside the game defined viewport
        if(mouseNow.y < gameBarTop || mouseNow.y > gameBarBottom ||  GUIScript.CheckClickOnRects(new Vector2(mouseNow.x,mouseNow.y)) )
            return;

        // Checks if we clicked in an unit
        Transform whatIClicked = GetWhatIClicked();

        // Possibilities:
        // 1-I don't have anything selected. In this case, select the object under the mouse cursor, if possible
        // 2-I already have select an object. In this case, the click will point where it should move
        if(whatIClicked != null) {

            // Get the basic info on the unit
            selectedBaseEntity = whatIClicked.gameObject.GetComponent<CBaseEntity>();

            if(selectedBaseEntity != null) {

                // Do not let we select enemy units
                if(selectedBaseEntity.Team == CBaseEntity.eObjTeam.Opponent) {

                    return;
                }

                if(selectedBaseEntity.Selectable) {

                    // Unit not selected?
                    if(!selectedBaseEntity.isSelected) {

                        // Unselect previous units
                        if(selectedObject != null) {
                            selectedObject.gameObject.GetComponent<CBaseEntity>().Deselect();
                            RemoveCursor();
                        }

                        // Select this unit
                        selectedObject = selectedBaseEntity.Select();

                        infoPanel.SetInfoLabel(selectedObject.gameObject.name);

                        if(selectedBaseEntity.Movable) {

                            // Change the mouse state
                            MouseState = eMouseStates.CanWalk;
                        }
                        else {

                            // FIXME: to avoid a previously selected drone to walk, even not being selected
                            MouseState = eMouseStates.Hover;
                        }
                    }
                }
            }
            else {

                // Unselect current object
                if(selectedObject != null) {

                    // Deselect the current selected object
                    selectedObject.gameObject.GetComponent<CBaseEntity>().Deselect();
                    selectedObject = null;
                    // Change the mouse state
                    MouseState = eMouseStates.Hover;
                    RemoveCursor();

                    // Reset the menu panel
                    mainScript.bottomMenu.PlayerInfoMenuEnable(null);
                }
            }
        }
    }
    // SelectObject
    public void SelectObject(Transform targetObject)
    {
        // Get the basic info on the unit
        selectedBaseEntity = targetObject.gameObject.GetComponent<CBaseEntity>();

        if(selectedBaseEntity != null) {

                // Do not let we select enemy units
                if(selectedBaseEntity.Team == CBaseEntity.eObjTeam.Opponent) {

                    return;
                }

                if(selectedBaseEntity.Selectable) {

                    // Unit not selected?
                    if(!selectedBaseEntity.isSelected) {

                        // Unselect previous units
                        if(selectedObject != null) {

                            selectedObject.gameObject.GetComponent<CBaseEntity>().Deselect();
                            RemoveCursor();
                        }

                        // Select this unit
                        selectedObject = selectedBaseEntity.Select();

                        infoPanel.SetInfoLabel(selectedObject.gameObject.name);

                        if(selectedBaseEntity.Movable) {

                            // Change the mouse state
                            MouseState = eMouseStates.CanWalk;
                        }
                }
            }

        }
    }
示例#15
0
 /// <summary>
 /// Changes the menu type to show the menu for building an extractor
 /// </summary>
 /// <param name="caller"> The CBaseEntity component of the caller of this method </param>
 public void BuildExtractorMenuEnable(CBaseEntity caller)
 {
     menuType = eMenuType.BuildExtractor;
     this.caller = caller;
 }
示例#16
0
 public CEnvTonemapController(CBaseEntity baseEnt) : base(baseEnt.index)
 {
 }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        if (gameObject.layer == MainScript.alliedLayer) {

            /*
            // DEBUG
            Debug.Log("Object " + gameObject.name + " is in layer Allied");
            //*/

            return;
        }

        if(AppearsToEnemy() && !visible){
            visible = true;
            if ( this.CompareTag("Resource")) {

                if (sfxRecursoLocalizado)
                    AudioSource.PlayClipAtPoint(sfxRecursoLocalizado, transform.position);

                // Send an event: we found a resource
                if(!cBaseEntity)
                    cBaseEntity = gameObject.GetComponent<CResource>();

                if(cBaseEntity != null) {

                    CResource cResource = cBaseEntity as CResource;
                    if(cResource.resourceType == CResource.eResourceType.Oxygen) {

                        mainScript.ReceiveNewEvent(this.transform, QuestManager.EQuestEvents.FOUND_WATER_RESOURCE);
                    }
                    if(cResource.resourceType == CResource.eResourceType.Metal) {

                        mainScript.ReceiveNewEvent(this.transform, QuestManager.EQuestEvents.FOUND_METAL_RESOURCE);
                    }
                }
                else {

                    // DEBUG
                    Debug.LogError(this.transform + "Couldn't find CBaseEntity in this object");
                }
            }

            if ( this.CompareTag("RocketPart"))
                if (sfxPecaLocalizada)
                    AudioSource.PlayClipAtPoint(sfxPecaLocalizada, transform.position);

            SetObjectVisible();
        }

        if (visible && !keepVisible){

            visible = AppearsToEnemy();

            if(this.CompareTag("Drone") || this.CompareTag("Monkey")){

                SetObjectVisible();
            }
            else
                renderer.enabled = visible;
        }
    }