void Update()
 {
     if (pc.attacking == false)
     {
         if (pc.direction.x >= 5)
         {
             attackDirection = AttackDirection.Up;
             DisableColliders();
         }
         else if (pc.direction.x <= -5)
         {
             attackDirection = AttackDirection.Down;
             DisableColliders();
         }
         else if (pc.direction.y <= -5)
         {
             attackDirection = AttackDirection.Left;
             DisableColliders();
         }
         else if (pc.direction.y >= 5)
         {
             attackDirection = AttackDirection.Right;
             DisableColliders();
         }
     }
 }
Exemple #2
0
        public static Vector3 getImpactPositionSimple(this ICombatant initialTarget, AbstractActor attacker, Vector3 attackPosition, int hitLocation)
        {
            Vector3         impactPoint     = initialTarget.CurrentPosition;
            AttackDirection attackDirection = AttackDirection.FromFront;

            if ((UnityEngine.Object)initialTarget.GameRep != (UnityEngine.Object)null)
            {
                impactPoint     = initialTarget.GameRep.GetHitPosition(hitLocation);
                attackDirection = initialTarget.Combat.HitLocation.GetAttackDirection(attackPosition, initialTarget);
                if (initialTarget.UnitType == UnitType.Building)
                {
                    impactPoint = attacker.Combat.LOS.GetBuildingHitPosition(attacker, initialTarget as BattleTech.Building, attackPosition, 100f, impactPoint);
                }
                else
                {
                    Vector3 origin    = attackPosition + attacker.HighestLOSPosition;
                    Vector3 vector3_2 = impactPoint - origin;
                    Ray     ray2      = new Ray(origin, vector3_2.normalized);
                    foreach (Collider allRaycastCollider in initialTarget.GameRep.AllRaycastColliders)
                    {
                        RaycastHit hitInfo;
                        if (allRaycastCollider.Raycast(ray2, out hitInfo, vector3_2.magnitude))
                        {
                            impactPoint = hitInfo.point;
                            break;
                        }
                    }
                }
            }
            return(impactPoint);
        }
        internal static ArmorLocation GetPassthroughLocation(
            ArmorLocation location,
            AttackDirection attackDirection
            )
        {
            try
            {
                if (ComponentExplosionsFeature.IsInternalExplosion && currentMech != null)
                {
                    var chassisLocation = MechStructureRules.GetChassisLocationFromArmorLocation(location);
                    var properties      = ComponentExplosionsFeature.Shared.GetCASEProperties(currentMech, (int)chassisLocation);
                    if (properties != null)
                    {
                        currentMech.PublishFloatieMessage("EXPLOSION CONTAINED");

                        //Control.mod.Logger.LogDebug($"prevented explosion pass through from {Mech.GetAbbreviatedChassisLocation(chassisLocation)}");

                        return(ArmorLocation.None); // CASE redirects damage, so lets redirect it to none
                    }
                }
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }

            return(MechStructureRules.GetPassthroughLocation(location, attackDirection));
        }
Exemple #4
0
        /// <summary>
        /// Calculates Crits on attack
        /// </summary>
        /// <remarks>
        /// This checks if we have FoTF. If we do Damage is calculated based on lost masks. otherwise we revert back to normal
        /// </remarks>
        /// <param name="dir"></param>
        public void OnAttack(AttackDirection dir)
        {
            Log("Attacking");

            defaultNailDamage = 5 + 4 * PlayerData.instance.GetInt("nailSmithUpgrades");

            if (PlayerData.instance.GetInt("nailDamage") != defaultNailDamage)
            {
                PlayerData.instance.SetInt("nailDamage", defaultNailDamage);
            }

            if (PlayerData.instance.GetBool("equippedCharm_6"))
            {
                Log("Stronger Attack");

                PlayerData.instance.SetInt("nailDamage",

                                           PlayerData.instance.GetInt("nailDamage") +

                                           4 * (PlayerData.instance.GetInt("maxHealth") - PlayerData.instance.GetInt("health")));

                PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");

                _NailDamageTracker = PlayerData.instance.GetInt("nailDamage");

                Log("Set Nail Damage to to " + _NailDamageTracker);
            }

            /// <summary>
            /// Reverts damage
            /// </summary>
            /// <remarks>After the attack is over, we need to reset the nail damage back to what it was.</remarks>
            /// <param name="dir"></param>
        }
Exemple #5
0
 public void Clear()
 {
     Index              = -1;
     AttackDir          = AttackDirection.Top;
     curState           = AnimalState.None;
     transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
 }
        private void DetectPlayer()
        {
            float xDiff = player.transform.position.x - transform.position.x;
            float yDiff = player.transform.position.y - transform.position.y;

            //en bas a gauche
            if (xDiff < 0 && yDiff < 0)
            {
                direction = AttackDirection.SouthWest;
            }
            //en bas a droite
            if (xDiff > 0 && yDiff < 0)
            {
                direction = AttackDirection.SouthEast;
            }
            //en haut a gauche
            if (xDiff < 0 && yDiff > 0)
            {
                direction = AttackDirection.NorthWest;
            }
            //en haut a droite
            if (xDiff > 0 && yDiff > 0)
            {
                direction = AttackDirection.NorthEast;
            }
        }
Exemple #7
0
        public string PlayerAttack(AttackDirection direction)
        {
            //for some reason I can only attack up and down but not left and right?

            int    visionIndex = (int)direction;
            string failMessage = "Hero attack failed";

            if (map.Hero.Vision[visionIndex].Type == TileType.ENEMY)
            {
                Enemy enemy = (Enemy)map.Hero.Vision[visionIndex];
                if (enemy.isDead())
                {
                    return(failMessage);
                }

                map.Hero.Attack(enemy);
                EnemiesAttack();
                map.Update();

                if (enemy.isDead())
                {
                    return("Hero killed enemy!");
                }

                return("Hero attacked enemy \n"
                       + "Enemy HP: " + enemy.HP + "/" + enemy.MaxHP);
            }

            return(failMessage);
        }
 public static void SetDirectionMarker(AttackDirectionIndicator __instance, AttackDirection direction)
 {
     try {
         AttackDirectionIndicator me = __instance;
         if (me.Owner == null || me.Owner.IsDead || Combat == null)
         {
             return;
         }
         Color    orig         = me.ColorInactive;
         Color?[] activeColors = __instance.Owner?.team?.IsFriendly(Combat?.LocalPlayerTeam) ?? false ? FacingMarkerPlayerColors : FacingMarkerEnemyColors;
         object[] colors;
         if (direction != AttackDirection.ToProne && direction != AttackDirection.FromTop)
         {
             colors = new object[] { activeColors?[0] ?? orig, activeColors?[1] ?? orig, activeColors?[2] ?? orig, activeColors?[3] ?? orig };
             if (direction != AttackDirection.None)
             {
                 int dirIndex = Math.Max(0, Math.Min((int)direction - 1, LOSDirectionCount - 1));
                 colors[dirIndex] = FacingMarkerTargetColors?[dirIndex] ?? me.ColorActive;
                 //Log( $"Direction {direction}, Index {dirIndex}, Color {colors[ dirIndex ]}" );
             }
         }
         else
         {
             if (ActiveState == null)
             {
                 return;
             }
             FiringPreviewManager.PreviewInfo info = ActiveState.FiringPreview.GetPreviewInfo(me.Owner);
             orig   = info.HasLOF ? (FacingMarkerTargetColors?[4] ?? me.ColorActive) : (activeColors?[4] ?? me.ColorInactive);
             colors = new object[] { orig, orig, orig, orig };
         }
         SetColors.Invoke(__instance, colors);
     }                 catch (Exception ex) { Error(ex); }
 }
Exemple #9
0
    private AttackDirection GetAttackDirection()
    {
        Vector2 direction;

        switch (attackDirectionSource)
        {
        default:
        case AttackDirectionSource.MOUSE:     // Get direction from screen
            Vector2 screenPoint = Input.mousePosition;
            direction = (Camera.main.ScreenToWorldPoint(screenPoint) - transform.position).normalized;
            break;

        case AttackDirectionSource.PLAYER:     // Get direction from player
            direction = movement.LastMoveDirection;
            break;
        }

        float           bestDot       = Vector2.Dot(direction, attackDirections[0].direction);
        AttackDirection bestDirection = attackDirections[0];

        for (int i = 1; i < attackDirections.Length; i++)
        {
            float dot = Vector2.Dot(direction, attackDirections[i].direction);
            if (dot > bestDot)
            {
                bestDot       = dot;
                bestDirection = attackDirections[i];
            }
        }
        return(bestDirection);
    }
        public KiteAi(AttackDirection ad, HeroType heroType)
            : base(heroType)
        {
            enemyTower = ad == AttackDirection.Left ? new Vec(100, 540) : new Vec(1820, 540);
            stepToBase = ad == AttackDirection.Left ? new Vec(70, 0) : new Vec(-70, 0);

            Logger.Log(enemyTower.ToString());
        }
Exemple #11
0
 /// <summary>
 /// Deploys the weapon.
 /// </summary>
 /// <param name="attackDirection">Attack direction.</param>
 public void DeployWeapon(AttackDirection attackDirection) //JY- player uses weapon
 {
     if (_weapon != null)
     {
         _weapon.Attack(_location, attackDirection);
     }
     MetaHandler.DisplayAmmunitionLevel(_weapon);
 }
Exemple #12
0
    void Move(AttackDirection direction)
    {
        Vector3 pos = transform.localPosition;

        pos.x += direction == AttackDirection.Right ? stepDistance : -stepDistance;
        pos.x  = Mathf.Clamp(pos.x, -maxDistance, maxDistance);
        transform.localPosition = pos;
    }
Exemple #13
0
 public bool HasDirection(AttackDirection d)
 {
     if (d == AttackDirection.ANY)
     {
         return(true);
     }
     return(d == (AttackDirection)direction.x || d == (AttackDirection)direction.y);
 }
 public static void RecordAttack(AttackDirector.AttackSequence __instance)
 {
     try {
         AttackDirector.AttackSequence me = __instance;
         AttackDirection direction        = Combat.HitLocation.GetAttackDirection(me.attackPosition, me.chosenTarget);
         float           range            = (me.attackPosition - me.chosenTarget.CurrentPosition).magnitude;
         BuildSequenceLine(me.attacker, me.chosenTarget, direction, range);
     }                 catch (Exception ex) { Error(ex); }
 }
Exemple #15
0
 public void CollectInfomation()
 {
     if (enemy == null)
     {
         return;
     }
     enemyAttackAnimationTime = enemy.animator.GetCurrentAnimatorStateInfo(MeleeController.attackLayer).normalizedTime;
     enemyAttackDirection     = (AttackDirection)enemy.animator.GetInteger(MeleeController.attackIndex);
 }
Exemple #16
0
        private void OnAfterAttack(AttackDirection dir)
        {
            if (Punishment != 0)
            {
                Punishment = 0;
            }
            if (PlayerData.instance.GetBool("equippedCharm_6"))
            {
                Punishment += 1;
            }
            if (PlayerData.instance.GetBool("equippedCharm_25"))
            {
                Punishment += 1;
            }
            if (PlayerData.instance.GetBool("equippedCharm_13"))
            {
                Punishment += 1;
            }
            if (PlayerData.instance.GetBool("equippedCharm_18"))
            {
                Punishment += 1;
            }
            if (PlayerData.instance.GetBool("equippedCharm_32"))
            {
                Punishment += 1;
            }
            if (Punishment == 4)
            {
                PlayerData.instance.overcharmed = true;

                HeroController.instance.ATTACK_DURATION = 0.51f;

                HeroController.instance.ATTACK_COOLDOWN_TIME = 0.45f;

                HeroController.instance.ATTACK_DURATION_CH = 0.25f;

                HeroController.instance.ATTACK_COOLDOWN_TIME_CH = 0.2f;
            }
            if (Punishment >= 6)
            {
                PlayerData.instance.overcharmed = true;

                PlayerData.instance.SetInt("nailDamage",

                                           1);

                PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");

                HeroController.instance.ATTACK_DURATION = 0.82f;

                HeroController.instance.ATTACK_COOLDOWN_TIME = 0.36f;

                HeroController.instance.ATTACK_DURATION_CH = 0.75f;

                HeroController.instance.ATTACK_COOLDOWN_TIME_CH = 0.36f;
            }
        }
        static Dictionary <VehicleChassisLocations, float> GetLocationDictionary(Vector3 attackerPosition, Vehicle targetVehicle, Vector3 targetPosition, Quaternion targetRotation)
        {
            //Dictionary<ArmorLocation, float> locDir = new Dictionary<ArmorLocation, float>();

            AttackDirection attackDirection   = GetAttackDirection(attackerPosition, targetVehicle, targetPosition, targetRotation);
            HitLocation     hitLocationHelper = targetVehicle.Combat.HitLocation;
            Dictionary <VehicleChassisLocations, int> hitTable = hitLocationHelper.GetVehicleHitTable(attackDirection, false);

            return(HitTableToLocationDirectory(hitTable));
        }
Exemple #18
0
 public AnimationData(string clip, float start, float hit, float end, float clipLength, AttackDirection direction, float damage)
 {
     Clip       = clip;
     Start      = start;
     Hit        = hit;
     End        = end;
     ClipLength = clipLength;
     Direction  = direction;
     Damage     = damage;
 }
Exemple #19
0
        AttackDirection getCombo(AttackDirection current)
        {
            var dir = (AttackDirection)MeleeController.r.Next(0, 5);

            if (dir == current)
            {
                return(getCombo(current));
            }
            return(dir);
        }
Exemple #20
0
        public void Schutz(AttackDirection aDir)
        {
            fireball = Instantiate(HeroController.instance.spell1Prefab, HeroController.instance.transform.position - new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0));

            fireball.transform.localScale = new Vector3(1f, 0.1f, 0.01f);

            fireballFSM = fireball.LocateMyFSM("Fireball Cast");

            fireballFSM.FsmVariables.GetFsmFloat("Fire Speed").Value = AmmunitionControl.currAmmoType.BulletVelocity;

            // Destroy the old camera shake actions and replace with a simple small shake.

            /*
             * FsmState fbState = fireballFSM.GetState("Cast Right");
             * fbState.Actions = fbState.Actions.Where(action => !(action is SendEventByName)).ToArray();
             * fbState = fireballFSM.GetState("Cast Left");
             * fbState.Actions = fbState.Actions.Where(action => !(action is SendEventByName)).ToArray();
             */

            // Shake screen
            GameCameras.instance.cameraShakeFSM.SendEvent("SmallShake");

            //This block removes the default audio and wall hit shake

            //Shooting toward the right
            if (HeroController.instance.cState.facingRight)
            {
                fireball.transform.position += new Vector3(0.80f, -0.8f, 0f);
                fireballFSM.GetAction <SendEventByName>("Cast Right", 1).sendEvent          = "";
                fireballFSM.GetAction <AudioPlayerOneShotSingle>("Cast Right", 6).volume    = 0;
                fireballFSM.GetAction <SpawnObjectFromGlobalPool>("Cast Right", 7).position = new Vector3(0, 0, 0);

                //Deviation/Recoil
                RecoilIncrease();
                recoilVal = recoilNum.Next(-AmmunitionControl.currAmmoType.CurrRecoilDeviation, AmmunitionControl.currAmmoType.CurrRecoilDeviation);
                fireball.transform.Rotate(new Vector3(0, 0, recoilVal + FireAtDiagonal()));
                fireballFSM.GetAction <SetVelocityAsAngle>("Cast Right", 9).angle = CheckIfRightAngle(0 + recoilVal + FireAtDiagonal());
            }
            //Shooting toward the left
            else if (!HeroController.instance.cState.facingRight)
            {
                fireball.transform.position += new Vector3(-0.80f, -0.8f, 0f);
                fireballFSM.GetAction <SendEventByName>("Cast Left", 1).sendEvent          = "";
                fireballFSM.GetAction <AudioPlayerOneShotSingle>("Cast Left", 3).volume    = 0;
                fireballFSM.GetAction <SpawnObjectFromGlobalPool>("Cast Left", 4).position = new Vector3(0, 0, 0);

                //Deviation/Recoil
                RecoilIncrease();
                recoilVal = recoilNum.Next(-AmmunitionControl.currAmmoType.CurrRecoilDeviation, AmmunitionControl.currAmmoType.CurrRecoilDeviation);
                fireball.transform.Rotate(new Vector3(0, 0, recoilVal - FireAtDiagonal()));
                fireballFSM.GetAction <SetVelocityAsAngle>("Cast Left", 6).angle = CheckIfRightAngle(180 + recoilVal - FireAtDiagonal());
            }

            //Destroy(fireball, 0.25f);
        }
 void decideFeint(AttackDirection dir)
 {
     if (tacticalControl.EnemyController.flinching || dir == AttackDirection.LTR)
     {
         willFeint = false;
     }
     else
     {
         willFeint = MeleeController.r.NextDouble() < feintProb;
     }
 }
Exemple #22
0
 public int GetPoint(AttackDirection dir)
 {
     if (dir == AttackDirection.Top)
     {
         return(b2tSide.Points);
     }
     else
     {
         return(t2bSide.Points);
     }
 }
Exemple #23
0
 public float GetLastConnectMoveDis(AttackDirection dir)
 {
     if (dir == AttackDirection.Top)
     {
         return(b2tSide.GetLastConnectMoveDis());
     }
     else
     {
         return(t2bSide.GetLastConnectMoveDis());
     }
 }
        static Dictionary <ArmorLocation, float> GetLocationDictionary(Vector3 attackerPosition, Mech m, Vector3 targetPosition, Quaternion targetRotation)
        {
            //Dictionary<ArmorLocation, float> locDir = new Dictionary<ArmorLocation, float>();

            // TODO handle called shots - see HitLocationRules.cs GetAdjacentHitLocation

            AttackDirection attackDirection          = GetAttackDirection(attackerPosition, m, targetPosition, targetRotation);
            HitLocation     hitLocationHelper        = m.Combat.HitLocation;
            Dictionary <ArmorLocation, int> hitTable = hitLocationHelper.GetMechHitTable(attackDirection, false);

            return(HitTableToLocationDirectory(hitTable));
        }
Exemple #25
0
    public float GetMaxDis(AttackDirection dir)
    {
        float maxDis = 0;

        if (dir == AttackDirection.Top)
        {
            maxDis = b2tSide.GetFirstMoveDis();
        }
        else
        {
            maxDis = t2bSide.GetFirstMoveDis();
        }
        return(maxDis);
    }
Exemple #26
0
 public override bool Attacked(AttackDirection direction, float damage)
 {
     Health -= damage;
     if (Health <= 0)
     {
         Health = 0;
         if (Handler)
         {
             Handler.Lost(this);
         }
     }
     Handler.ActorHit(this);
     return(true);
 }
 public static void PrefixMechCalledShot(ref Dictionary <ArmorLocation, int> hitTable, ArmorLocation bonusLocation, ref float bonusLocationMultiplier)
 {
     try {
         bonusLocationMultiplier = FixMultiplier(bonusLocation, bonusLocationMultiplier);
         if (Settings.CalledShotUseClustering && CurrentHitDirection != AttackDirection.None)
         {
             if (bonusLocation != ArmorLocation.None)
             {
                 hitTable = CombatConstants.GetMechClusterTable(bonusLocation, CurrentHitDirection);
             }
             CurrentHitDirection = AttackDirection.None;
         }
     }                 catch (Exception ex) { Error(ex); }
 }
Exemple #28
0
        public void handleMainHandResponse()
        {
            var mainHandAction         = Input.GetMouseButtonDown(0);
            var mouseScrollDelta       = Input.mouseScrollDelta.y;
            var currentAttackDirection = getCurrentAttackDirection;
            var kicking = Input.GetKeyDown(KeyCode.E);

            if (Input.GetKeyDown(KeyCode.Q))
            {
                feint();
                return;
            }

            AttackDirection response = AttackDirection.NODIRECTION;

            if (kicking)
            {
                response = AttackDirection.KICK;
                executeAttack(response, Bodypart.RIGHTFOOT);
                return;
            }
            else
            {
                if (mainHandAction)
                {
                    if (currentAttackDirection == AttackDirection.NODIRECTION || currentAttackDirection == AttackDirection.LTR)
                    {
                        response = AttackDirection.RTL;
                    }
                    else
                    {
                        response = AttackDirection.LTR;
                    }
                }
                else if (mouseScrollDelta > 0)
                {
                    response = AttackDirection.UPWARD;
                }
                else if (mouseScrollDelta < 0)
                {
                    response = AttackDirection.DOWN;
                }
                else if (Input.GetMouseButtonDown(2))
                {
                    response = AttackDirection.THRUST;
                }
            }
            executeAttack(response, Bodypart.RIGHTHAND);
        }
Exemple #29
0
 public void InitData(AttackDirection dir, List <RoadEntity> roads)
 {
     AttackDir     = dir;
     m_roads       = roads;
     UseAI.StartAI = true;
     BattleDatas   = new AIBattleInfo[roads.Count];
     for (int i = 0; i < roads.Count; i++)
     {
         BattleDatas[i] = new AIBattleInfo();
     }
     for (int i = 0; i < SeatList.Count; i++)
     {
         SeatList[i].SeatIndex = i;
     }
 }
Exemple #30
0
    public virtual void StartAttack(AttackDirection direction, AttackTrigger trigger)
    {
        // if we're attacking and can't cancel, then return
        if (isAttacking && !canCancel)
        {
            return;
        }

        // get the movement controller state
        AttackPositionState state;

        if (movementControl.isJumping || movementControl.isFalling)
        {
            state = AttackPositionState.Air;
        }
        else if (movementControl.isDashing)
        {
            state = AttackPositionState.Dash;
        }
        else
        {
            state = AttackPositionState.Neutral;
        }

        if (InputAttackData[state][direction][trigger].Count != 0)
        {
            if (isAttacking && InputAttackData[state][direction][trigger].ContainsKey(currentAttack.attackID))
            {
                // go to the combo action this combination is associated with
                currentAttack = InputAttackData[state][direction][trigger][currentAttack.attackID];
            }
            else if (InputAttackData[state][direction][trigger].ContainsKey(""))
            {
                // go to the non-combo action this combination is associated with
                currentAttack = InputAttackData[state][direction][trigger][""];
            }
            else
            {
                // there is no attack available for this attack, return
                return;
            }

            // start the attack
            isAttacking = true;
            canCancel   = false;
            currentAttack.Activate();
        }
    }
Exemple #31
0
 void Start()
 {
     wherePlayer = AttackDirection.None;
     currentAttackCooldown = attackRate;
     gameController = GameObject.Find("Main Camera").GetComponent<GameController>();
     mob = gameController.mob;
     foreach (Mob m in mob)
     {
         if (m.mobBody == this.gameObject)
             thisMob = m;
         else
         {
             thisMob = new Mob();
             thisMob.isPirate = true;
             thisMob.mobBody = this.gameObject;
         }
     }
     //Debug.Log(thisMob +" "+ mob.IndexOf(thisMob) + " " + thisMob.isPirate);
     player = GameObject.Find("Player");
     rb2d = this.GetComponent<Rigidbody2D>();
     mobAnimator = this.GetComponent<Animator>();
     thisTransform = transform;
 }
    public virtual void StartAttack(AttackDirection direction, AttackTrigger trigger)
    {
        // if we're attacking and can't cancel, then return
        if (isAttacking && !canCancel) {
            return;
        }

        // get the movement controller state
        AttackPositionState state;
        if (movementControl.isJumping || movementControl.isFalling) {
            state = AttackPositionState.Air;
        } else if (movementControl.isDashing) {
            state = AttackPositionState.Dash;
        } else {
            state = AttackPositionState.Neutral;
        }

        if (InputAttackData[state][direction][trigger].Count != 0) {

            if (isAttacking && InputAttackData[state][direction][trigger].ContainsKey (currentAttack.attackID)) {

                // go to the combo action this combination is associated with
                currentAttack = InputAttackData[state][direction][trigger][currentAttack.attackID];

            } else if (InputAttackData[state][direction][trigger].ContainsKey ("")) {

                // go to the non-combo action this combination is associated with
                currentAttack = InputAttackData[state][direction][trigger][""];

            } else {

                // there is no attack available for this attack, return
                return;
            }

            // start the attack
            isAttacking = true;
            canCancel = false;
            currentAttack.Activate ();
        }
    }