Represents the controllable unit
Inheritance: MonoBehaviour
    private void castShadowBall()
    {
        ControllableUnit unit = GetObjects.instance.getControllableUnit();

        Instantiate(shadowBall, unit.transform.TransformPoint(spawnPosition),
                    unit.transform.rotation, GetObjects.instance.getAttackParticleContainer());
    }
Example #2
0
    private void meleeAnimationEvent()
    {
        // Access the unit
        ControllableUnit unit = GetObjects.instance.getControllableUnit();

        // Deal melee damage
        unit.doMeleeDamage(1.0f, meleeDamage);

        // Play the melee particle, initialize it if needed
        if (!particleInitialized)
        {
            createMeleeParticle();
        }

        meleeParticle.SetActive(false);
        meleeParticle.SetActive(true);

        // Play the melee sound if we have one
        if (meleeNoise)
        {
            unit.getSource().PlayOneShot(meleeNoise);
        }

        // Increment the attack number so we keep playing different animations
        meleeAttackNumber++;
        if (meleeAttackNumber > 2)
        {
            meleeAttackNumber = 0;
        }
    }
    public override void releaseFunctionConcrete(Vector3 localPos, Vector3 worldPos, Quaternion localRot, Quaternion worldRot)
    {
        // Hide the pointer and aoe indicator
        player.hidePointers();
        aoeIndicator.SetActive(false);

        // Get access to the unit
        ControllableUnit unit = GetObjects.instance.getControllableUnit();

        // Check that the unit isn't already attacking
        if (unit.getAttacking())
        {
            return;
        }

        // Raycast onto the defensive grid
        Vector3 raycastPoint;

        if (!raycastTheGround(worldPos, worldRot, out raycastPoint))
        {
            return;
        }

        // Set the spawn position for the object to be our raycast point
        currentCastPosition = raycastPoint;
        // Have the unit face the point we're casting towards
        unit.transform.LookAt(currentCastPosition, Vector3.up);
        // Have the unit cast this spell
        unit.castSpell(spawnCorpseObjectsOnCast);
    }
Example #4
0
 void Start()
 {
     controllerStartPosition = Vector3.zero;
     objectToMove            = GetObjects.instance.getMovingObjectsContainer().gameObject;
     bounds            = GetObjects.instance.GetLevelBounds();
     playerCharacter   = GetObjects.instance.getControllableUnit();
     player            = GetObjects.instance.getPlayer();
     startingMoveSpeed = moveSpeed;
 }
 public void AddUnitsForTeamB(ControllableUnit controllableUnit)
 {
     if(this.teamBUnits.ContainsKey(controllableUnit.GetUnitName())) {
         Debug.LogError("Cannot add " +controllableUnit.GetUnitName()+ ". It already exists for team B roster.");
     }
     else {
         this.teamBUnits.Add(controllableUnit.GetUnitName(), controllableUnit);
     }
 }
Example #6
0
    void joysticksUpdate()
    {
        // Make sure we can get the controllable unit
        ControllableUnit unit = GetObjects.instance.getControllableUnit();

        if (unit == null)
        {
            return;
        }
        // Get the camera to translate movement to the player's perspective
        GameObject playerCamera = GetObjects.instance.getCamera();

        // Take in input from the player
        Vector2 leftInput  = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
        Vector2 rightInput = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);

        // Take in gamepad input if we don't have an OVR controller
        if (OVRInput.GetActiveController() == OVRInput.Controller.None)
        {
            leftInput  = new Vector2(Input.GetAxis("Move_X_Axis"), Input.GetAxis("Move_Y_Axis"));
            rightInput = new Vector2(Input.GetAxis("Look_X_Axis"), Input.GetAxis("Look_Y_Axis"));
        }

        // Find the look vector of the unit
        Vector3 lookVector = new Vector3(rightInput.x, 0.0f, rightInput.y);
        // Find the movement vector of the unit
        Vector3 movementVector = new Vector3(leftInput.x, 0.0f, leftInput.y);
        // Determine whether the unit should strafe or not
        bool isStrafing = lookVector != Vector3.zero;

        // Figure out where the unit should look
        if (lookVector == Vector3.zero && movementVector == Vector3.zero)
        {
            lookVector = unit.transform.forward;
        }
        else if (lookVector == Vector3.zero)
        {
            lookVector = playerCamera.transform.rotation * movementVector;
        }
        else
        {
            lookVector = playerCamera.transform.rotation * lookVector;
        }

        lookVector.y = 0.0f;

        // Make the movement relative to the player's camera
        movementVector   = playerCamera.transform.rotation * movementVector;
        movementVector.y = 0.0f;
        // Transform the movement into the controllable unit's space before passing it along
        movementVector = Quaternion.Inverse(unit.transform.rotation) * movementVector;

        // Update the unit's movement
        unit.movementUpdate(movementVector, lookVector, isStrafing);
    }
 public void AddUnitsForTeamB(ControllableUnit controllableUnit)
 {
     if (this.teamBUnits.ContainsKey(controllableUnit.GetUnitName()))
     {
         Debug.LogError("Cannot add " + controllableUnit.GetUnitName() + ". It already exists for team B roster.");
     }
     else
     {
         this.teamBUnits.Add(controllableUnit.GetUnitName(), controllableUnit);
     }
 }
    public void Perform(ControllableUnit sourceUnit, ControllableUnit targetUnit)
    {
        AttributeBonus damageOutcome = new AttributeBonus(-2,1);

        HealthAttribute healthAttribute = targetUnit.GetCharacterData().GetHealthAttribute();
        healthAttribute.AddAttributeBonus(damageOutcome);

        Debug.Log ("Normal attack skill to " +targetUnit+ ". Unit new HP is: " +targetUnit.GetCharacterData().GetHealthAttribute().GetModifiedValue());

        this.PerformAnimation(sourceUnit, targetUnit);
    }
    /// <summary>
    /// Perform animation for the controllable units here
    /// </summary>
    private void PerformAnimation(ControllableUnit sourceUnit, ControllableUnit targetUnit)
    {
        //sourceUnit.transform.DOMove(targetUnit.transform,1.0f).SetEase(Ease.
        Vector3 originalSourcePos = sourceUnit.transform.localPosition;
        Vector3 targetPos = targetUnit.transform.localPosition;

        Sequence tweenSequence = DOTween.Sequence();
        tweenSequence.Append(sourceUnit.transform.DOMove(targetPos, 1.0f).SetEase(Ease.OutExpo));
        tweenSequence.Append(sourceUnit.transform.DOMove(originalSourcePos, 1.0f).SetEase(Ease.OutExpo));
        tweenSequence.OnComplete(this.onFinishAction);

        tweenSequence.Play();
    }
    public void Perform(ControllableUnit sourceUnit, ControllableUnit targetUnit)
    {
        AttributeBonus damageOutcome = new AttributeBonus(-2, 1);

        HealthAttribute healthAttribute = targetUnit.GetCharacterData().GetHealthAttribute();

        healthAttribute.AddAttributeBonus(damageOutcome);

        Debug.Log("Normal attack skill to " + targetUnit + ". Unit new HP is: " + targetUnit.GetCharacterData().GetHealthAttribute().GetModifiedValue());


        this.PerformAnimation(sourceUnit, targetUnit);
    }
    /// <summary>
    /// Perform animation for the controllable units here
    /// </summary>
    private void PerformAnimation(ControllableUnit sourceUnit, ControllableUnit targetUnit)
    {
        //sourceUnit.transform.DOMove(targetUnit.transform,1.0f).SetEase(Ease.
        Vector3 originalSourcePos = sourceUnit.transform.localPosition;
        Vector3 targetPos         = targetUnit.transform.localPosition;

        Sequence tweenSequence = DOTween.Sequence();

        tweenSequence.Append(sourceUnit.transform.DOMove(targetPos, 1.0f).SetEase(Ease.OutExpo));
        tweenSequence.Append(sourceUnit.transform.DOMove(originalSourcePos, 1.0f).SetEase(Ease.OutExpo));
        tweenSequence.OnComplete(this.onFinishAction);

        tweenSequence.Play();
    }
Example #12
0
    private void createMeleeParticle()
    {
        ControllableUnit unit = GetObjects.instance.getControllableUnit();

        if (unit == null)
        {
            return;
        }
        GameObject instantiatedMeleeParticle = Instantiate(meleeParticle, unit.gameObject.transform, false);

        instantiatedMeleeParticle.transform.localPosition = meleeParticle.transform.position;
        instantiatedMeleeParticle.transform.localRotation = meleeParticle.transform.rotation;
        instantiatedMeleeParticle.SetActive(false);
        meleeParticle       = instantiatedMeleeParticle;
        particleInitialized = true;
    }
Example #13
0
    /// <summary>
    /// This is like an update function
    /// </summary>
    public void DoAction()
    {
        if (this.actionPermitted == false)
        {
            return;
        }

        ControllableUnit enemyUnit  = BattleComposition.Instance.GetUnitAtTeamB(0);
        ControllableUnit playerUnit = BattleComposition.Instance.GetUnitAtTeamA(0);        //TODO: just get first player unit

        ISkill normalSkill = SkillsManager.Instance.GetSkill(enemyUnit.GetUnitIdentity(), SkillNamesHolder.NORMAL_ATTACK_SKILL);

        normalSkill.AddOnFinishAction(this.OnSkillFinished);
        normalSkill.Perform(enemyUnit, playerUnit);

        this.actionPermitted = false;
    }
    private void ProcessMouseDown(Collider hitObject)
    {
        if(hitObject != null) {

            ControllableUnit controllableUnit = hitObject.gameObject.GetComponent<ControllableUnit>();

            if(controllableUnit != null) {
                this.controllableUnit = controllableUnit;
                this.activated = false;
            }

        }
        else {
            Debug.Log ("No object hit. Deactivating input controller.");
            this.activated = false;
        }
    }
Example #15
0
    private void ProcessMouseDown(Collider hitObject)
    {
        if (hitObject != null)
        {
            ControllableUnit controllableUnit = hitObject.gameObject.GetComponent <ControllableUnit>();

            if (controllableUnit != null)
            {
                this.controllableUnit = controllableUnit;
                this.activated        = false;
            }
        }
        else
        {
            Debug.Log("No object hit. Deactivating input controller.");
            this.activated = false;
        }
    }
 // Token: 0x06000029 RID: 41 RVA: 0x00008018 File Offset: 0x00006218
 public void Orbwalk(ControllableUnit controllable, bool attack, bool move)
 {
     if (this.issuedAction.IsSleeping)
     {
         return;
     }
     if (this.unitIssuedAction.IsSleeping(controllable.Handle))
     {
         return;
     }
     if (!controllable.Orbwalk(this.targetManager.Target, attack, move, null))
     {
         return;
     }
     this.issuedActionTimings[controllable.Handle] = Game.RawGameTime;
     this.unitIssuedAction.Sleep(controllable.Handle, 0.1f);
     this.issuedAction.Sleep(0.05f);
 }
    private void OnReceiveUnitPosition(Parameters parameters)
    {
        Vector3 viewportPos = (Vector3)parameters.GetObjectExtra(UNIT_POSITION_KEY);
        Vector3 unitPos     = Vector3.zero;

        unitPos.x = viewportPos.x * UIStats.Instance.GetReferenceWidth();
        unitPos.y = viewportPos.y * UIStats.Instance.GetReferenceHeight();

        ControllableUnit unit = (ControllableUnit)parameters.GetObjectExtra(CONTROLLABLE_UNIT_KEY);

        //instantiate hp bar prefab.
        HPBarElement hpBar = GameObject.Instantiate(hpBarPrefab) as HPBarElement;

        hpBar.transform.gameObject.name = this.hpBarPrefab.name;
        hpBar.transform.localPosition   = unitPos;
        hpBar.transform.SetParent(this.transform, false);
        hpBar.AssignControllableUnit(unit);

        this.hpBarList.Add(hpBar);
    }
Example #18
0
    public void InitializeTeamRoster()
    {
        foreach (ControllableUnit controllableUnit in this.teamAUnitRoster)
        {
            ControllableUnit unitInstance = GameObject.Instantiate(controllableUnit) as ControllableUnit;

            unitInstance.transform.localPosition = this.teamAPosition.localPosition;
            unitInstance.transform.SetParent(BattleSystemHandler.Instance.transform, false);

            BattleComposition.Instance.AddUnitsForTeamA(unitInstance);
        }

        foreach (ControllableUnit controllableUnit in this.teamBUnitRoster)
        {
            ControllableUnit unitInstance = GameObject.Instantiate(controllableUnit) as ControllableUnit;
            unitInstance.transform.localPosition = this.teamBPosition.localPosition;
            unitInstance.transform.SetParent(BattleSystemHandler.Instance.transform, false);

            BattleComposition.Instance.AddUnitsForTeamB(unitInstance);
        }
    }
    void LateUpdate()
    {
        unitsInDragBox.Clear();

        if ((userIsDragging || finishDragOnThisFrame) && unitsOnScreen.Count > 0)
        {
            for (int i = 0; i < unitsOnScreen.Count; i++)
            {
                CharacterStats   unitObj    = unitsOnScreen[i] as CharacterStats;
                ControllableUnit unitScript = unitObj.GetComponent <ControllableUnit>();

                if (!UnitAlreadyInDragBoxUnits(unitObj))
                {
                    if (UnitInsideDragBox(unitScript.screenPos))
                    {
                        unitObj.selected = true;
                        unitsInDragBox.Add(unitObj);
                        Debug.Log(unitsInDragBox.Count);
                    }
                    else
                    {
                        if (!UnitIsAlreadyInSelectedUnits(unitObj))
                        {
                            unitObj.selected = false;
                        }
                        unitScript.selected = false;
                    }
                }
            }
        }

        if (finishDragOnThisFrame)
        {
            finishDragOnThisFrame = false;
            PutDraggedUnitsInSelectedUnits();
        }
    }
Example #20
0
    public void DoAction()
    {
        //like an update function
        if (this.performAction == false)
        {
            return;
        }

        //get selected controllable unit to apply skill
        ControllableUnit controllableUnit = BattleInputController.Instance.GetLastTouchedUnit();
        ControllableUnit selectedUnit     = BattleComposition.Instance.GetUnitAtTeamA(0);     //select 1st unit for the meantime.

        if (controllableUnit != null && controllableUnit != selectedUnit)
        {
            Debug.Log("Hoooman selected " + controllableUnit);
            this.performAction = false;

            ISkill normalSkill = SkillsManager.Instance.GetSkill(selectedUnit.GetUnitIdentity(), SkillNamesHolder.NORMAL_ATTACK_SKILL);
            normalSkill.AddOnFinishAction(this.OnSkillFinished);
            normalSkill.Perform(selectedUnit, controllableUnit);

            BattleInputController.Instance.ReleaseTouchedUnit();
        }
    }
 // Use this for initialization
 void Start()
 {
     player                = GetObjects.instance.getPlayer();
     playerUnit            = GetObjects.instance.getControllableUnit();
     playerInitialPosition = player.transform.parent.localPosition;
 }
 // Token: 0x060004CD RID: 1229 RVA: 0x00019434 File Offset: 0x00017634
 protected override void OnAbilityAdded(Ability9 entity)
 {
     try
     {
         ActiveAbility activeAbility;
         if (entity.IsControllable && entity.Owner.CanUseAbilities && entity.Owner.IsAlly(this.owner) && (activeAbility = (entity as ActiveAbility)) != null)
         {
             Unit9     abilityOwner = entity.Owner;
             Morphling morphling    = entity.Owner as Morphling;
             if (morphling != null && morphling.IsMorphed)
             {
                 ControllableUnit controllableUnit;
                 Type             type;
                 if (this.unitTypes.TryGetValue(morphling.MorphedHero.Name, out type))
                 {
                     controllableUnit = this.controllableUnits.Find((ControllableUnit x) => x.Handle == abilityOwner.Handle && x.GetType() == type);
                     if (controllableUnit == null)
                     {
                         controllableUnit = (ControllableUnit)Activator.CreateInstance(type, new object[]
                         {
                             abilityOwner,
                             this.abilitySleeper,
                             this.orbwalkSleeper[abilityOwner.Handle],
                             base.GetUnitMenu(abilityOwner)
                         });
                         controllableUnit.FailSafe        = base.BaseHero.FailSafe;
                         controllableUnit.MorphedUnitName = morphling.MorphedHero.Name;
                         foreach (ActiveAbility ability in (from x in abilityOwner.Abilities
                                                            where x.IsItem
                                                            select x).OfType <ActiveAbility>())
                         {
                             controllableUnit.AddAbility(ability, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                         }
                         this.controllableUnits.Add(controllableUnit);
                     }
                 }
                 else
                 {
                     controllableUnit = this.controllableUnits.Find((ControllableUnit x) => x.Handle == abilityOwner.Handle && x is DynamicUnit);
                     if (controllableUnit == null)
                     {
                         controllableUnit = new DynamicUnit(abilityOwner, this.abilitySleeper, this.orbwalkSleeper[abilityOwner.Handle], base.GetUnitMenu(abilityOwner), base.BaseHero)
                         {
                             FailSafe        = base.BaseHero.FailSafe,
                             MorphedUnitName = morphling.MorphedHero.Name
                         };
                         foreach (ActiveAbility ability2 in (from x in abilityOwner.Abilities
                                                             where x.IsItem
                                                             select x).OfType <ActiveAbility>())
                         {
                             controllableUnit.AddAbility(ability2, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                         }
                         this.controllableUnits.Add(controllableUnit);
                     }
                 }
                 if (activeAbility.IsItem)
                 {
                     IEnumerable <ControllableUnit> controllableUnits = this.controllableUnits;
                     Func <ControllableUnit, bool>  predicate;
                     Func <ControllableUnit, bool> < > 9__4;
                     if ((predicate = < > 9__4) == null)
                     {
                         predicate = (< > 9__4 = ((ControllableUnit x) => x.Handle == abilityOwner.Handle));
                     }
                     using (IEnumerator <ControllableUnit> enumerator2 = controllableUnits.Where(predicate).GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             ControllableUnit controllableUnit2 = enumerator2.Current;
                             controllableUnit2.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                         }
                         goto IL_3D3;
                     }
                 }
                 controllableUnit.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                 IL_3D3 :;
             }
             else
             {
                 if (activeAbility.IsItem)
                 {
                     IEnumerable <ControllableUnit> controllableUnits2 = this.controllableUnits;
                     Func <ControllableUnit, bool>  predicate2;
                     Func <ControllableUnit, bool> < > 9__5;
                     if ((predicate2 = < > 9__5) == null)
                     {
                         predicate2 = (< > 9__5 = ((ControllableUnit x) => x.Handle == abilityOwner.Handle));
                     }
                     using (IEnumerator <ControllableUnit> enumerator2 = controllableUnits2.Where(predicate2).GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             ControllableUnit controllableUnit3 = enumerator2.Current;
                             controllableUnit3.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                         }
                         goto IL_488;
                     }
                 }
                 ControllableUnit controllableUnit4 = this.controllableUnits.Find((ControllableUnit x) => x.Handle == entity.Owner.Handle);
                 if (controllableUnit4 != null)
                 {
                     controllableUnit4.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu);
                 }
                 IL_488 :;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, null);
     }
 }
Example #23
0
    /* --------------------------------------------------------------------- */

    #region Construction

    #endregion

    /* --------------------------------------------------------------------- */

    #region Unity Methods

    /// <summary>
    /// Unity Start event handler.
    /// </summary>
    void Start()
    {
        this._distanceFromPivot = Vector3.Distance(Vector3.up * Camera.main.transform.position.y, Camera.main.transform.position);
        Debug.Log(_distanceFromPivot);

        this._hexes = new List <BattleHex>();

        this._battleMouse    = GetComponent <BattleMouse>();
        this._battleKeyboard = GetComponent <BattleKeyboard>();

        float halfLength = 1;// / (float)Math.Cos( 30 * Math.PI / 180d );
        float fullLength = 2 * halfLength;

        Point2D gridSize = new Point2D(12, 9);
        Dictionary <Point2D, BattleHex> hexGrid = new Dictionary <Point2D, BattleHex>();

        this._turnManager = FindObjectOfType <TurnManager>();

        this._units        = FindObjectsOfType <ControllableUnit>().ToList();
        this._player2Units = FindObjectsOfType <AIControlledUnit>().ToList();

        for (int y = 0; y < gridSize.Y; y++)
        {
            int sizeX = gridSize.X;

            if (y % 2 != 0 && (gridSize.X + 0.5f) * fullLength > 10f)
            {
                --sizeX;
            }

            for (int x = 0; x < sizeX; x++)
            {
                GameObject hex          = (GameObject)Instantiate(this._hexTemplate);
                BattleHex  hexComponent = hex.GetComponent <BattleHex>();
                hexComponent.Configure(x, y, gridSize, fullLength, transform.gameObject);

                hexGrid.Add(new Point2D(x, y), hexComponent);
                this._hexes.Add(hexComponent);
            }
        }

        foreach (var hexItem in hexGrid)
        {
            hexItem.Value.FindNeighbours(hexGrid);
        }

        int index = 0;

        for (int i = 0; i < this._units.Count; i++)
        {
            ControllableUnit unit = _units[i];

            unit.InitialiseWithTile(this, _hexes[index], 90f);

            index += gridSize.X - i % 2;
        }

        for (int i = 0; i < this._player2Units.Count; i++)
        {
            this._player2Units[i].InitialiseWithTile(this, this._hexes[this._hexes.Count - i - 1], 270f);
        }

        this._turnManager.FinishTurn();
    }
 // Token: 0x060009F9 RID: 2553 RVA: 0x0002B730 File Offset: 0x00029930
 private void OnUpdate()
 {
     try
     {
         if (!this.Sleeper.IsSleeping)
         {
             Unit9 unit = base.TargetManager.TargetLocked ? base.TargetManager.Target : this.killSteal.Target;
             if (unit != null && unit.IsValid && unit.IsVisible)
             {
                 foreach (KeyValuePair <ActiveAbility, float> keyValuePair in this.abilityTimings.ToList <KeyValuePair <ActiveAbility, float> >())
                 {
                     ActiveAbility ability = keyValuePair.Key;
                     if (ability.IsValid && ability.BaseAbility.IsInAbilityPhase)
                     {
                         Unit9            owner           = ability.Owner;
                         float            value           = keyValuePair.Value;
                         PredictionInput9 predictionInput = ability.GetPredictionInput(unit, null);
                         predictionInput.Delay = Math.Max(value - Game.RawGameTime, 0f) + ability.ActivationDelay;
                         PredictionOutput9 predictionOutput = ability.GetPredictionOutput(predictionInput);
                         Vector3           vector;
                         if (ability is IHasRadius && this.abilityPositions.TryGetValue(ability.Handle, out vector))
                         {
                             Polygon       polygon  = null;
                             ActiveAbility ability2 = ability;
                             if (ability2 != null)
                             {
                                 AreaOfEffectAbility areaOfEffectAbility;
                                 if ((areaOfEffectAbility = (ability2 as AreaOfEffectAbility)) == null)
                                 {
                                     CircleAbility circleAbility;
                                     if ((circleAbility = (ability2 as CircleAbility)) == null)
                                     {
                                         ConeAbility coneAbility;
                                         if ((coneAbility = (ability2 as ConeAbility)) == null)
                                         {
                                             LineAbility lineAbility;
                                             if ((lineAbility = (ability2 as LineAbility)) != null)
                                             {
                                                 LineAbility lineAbility2 = lineAbility;
                                                 polygon = new Polygon.Rectangle(owner.Position, Vector3Extensions.Extend2D(owner.Position, vector, lineAbility2.Range), lineAbility2.Radius + 50f);
                                             }
                                         }
                                         else
                                         {
                                             ConeAbility coneAbility2 = coneAbility;
                                             polygon = new Polygon.Trapezoid(Vector3Extensions.Extend2D(owner.Position, vector, -coneAbility2.Radius / 2f), Vector3Extensions.Extend2D(owner.Position, vector, coneAbility2.Range), coneAbility2.Radius + 50f, coneAbility2.EndRadius + 100f);
                                         }
                                     }
                                     else
                                     {
                                         CircleAbility circleAbility2 = circleAbility;
                                         polygon = new Polygon.Circle(vector, circleAbility2.Radius + 50f, 20);
                                     }
                                 }
                                 else
                                 {
                                     AreaOfEffectAbility areaOfEffectAbility2 = areaOfEffectAbility;
                                     polygon = new Polygon.Circle(vector, areaOfEffectAbility2.Radius + 50f, 20);
                                 }
                             }
                             if (polygon != null && (!unit.IsAlive || predictionOutput.HitChance == null || !polygon.IsInside(predictionOutput.TargetPosition)))
                             {
                                 this.Sleeper.Sleep(0.15f);
                                 this.abilityTimings.Remove(ability);
                                 this.abilityPositions.Remove(ability.Handle);
                                 this.OrbwalkSleeper.Reset(ability.Owner.Handle);
                                 this.AbilitySleeper.Reset(ability.Handle);
                                 this.killSteal.KillStealSleeper.Reset();
                                 unit.RefreshUnitState();
                                 ability.Owner.BaseUnit.Stop();
                                 ControllableUnit controllableUnit = base.BaseHero.UnitManager.AllControllableUnits.FirstOrDefault((ControllableUnit x) => x.Handle == ability.Owner.Handle);
                                 if (controllableUnit != null)
                                 {
                                     controllableUnit.ComboSleeper.Reset();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, null);
     }
 }
Example #25
0
 public void ReleaseTouchedUnit()
 {
     this.controllableUnit = null;
 }
 public void AssignControllableUnit(ControllableUnit unit)
 {
     this.assignedUnit = unit;
 }
Example #27
0
 public AbilityHelper(TargetManager targetManager, IComboModeMenu comboModeMenu, ControllableUnit controllableUnit)
 {
     this.unit           = controllableUnit.Owner;
     this.TargetManager  = targetManager;
     this.comboSleeper   = controllableUnit.ComboSleeper;
     this.orbwalkSleeper = controllableUnit.OrbwalkSleeper;
     this.menu           = comboModeMenu;
 }
 public void ReleaseTouchedUnit()
 {
     this.controllableUnit = null;
 }
Example #29
0
        private void OnUnitAdded(Unit9 entity)
        {
            try
            {
                if (!entity.IsControllable || !entity.IsAlly(this.owner.Team))
                {
                    return;
                }

                if (this.ignoredUnits.Contains(entity.Name) || this.controllableUnits.Any(x => x.Handle == entity.Handle))
                {
                    return;
                }

                if (!this.controlAllies)
                {
                    if (entity.IsHero)
                    {
                        if (entity.BaseOwner?.Handle != this.owner.PlayerHandle)
                        {
                            return;
                        }
                    }
                    else if (entity.BaseOwner?.Handle != this.owner.HeroHandle)
                    {
                        return;
                    }
                }

                if (!entity.CanUseAbilities || !this.unitTypes.TryGetValue(entity.Name, out var type))
                {
                    if (entity.CanUseAbilities)
                    {
                        var d = new DynamicUnit(
                            entity,
                            this.abilitySleeper,
                            this.orbwalkSleeper[entity.Handle],
                            this.GetUnitMenu(entity),
                            this.BaseHero)
                        {
                            FailSafe = this.BaseHero.FailSafe
                        };

                        this.controllableUnits.Add(d);
                    }
                    else
                    {
                        var c = new ControllableUnit(
                            entity,
                            this.abilitySleeper,
                            this.orbwalkSleeper[entity.Handle],
                            this.GetUnitMenu(entity))
                        {
                            FailSafe = this.BaseHero.FailSafe
                        };

                        this.controllableUnits.Add(c);
                    }

                    return;
                }

                var ac = (ControllableUnit)Activator.CreateInstance(
                    type,
                    entity,
                    this.abilitySleeper,
                    this.orbwalkSleeper[entity.Handle],
                    this.GetUnitMenu(entity));
                ac.FailSafe = this.BaseHero.FailSafe;

                this.controllableUnits.Add(ac);
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }