Exemple #1
0
    private void Awake()
    {
        playerBehaviour      = this;
        playerAnimator       = GetComponent <Animator>();
        playerAudioSource    = GetComponent <AudioSource>();
        GroudedCollider      = GetComponent <CapsuleCollider>();
        animationHash        = GetComponent <AnimationHash>();
        playerRigidbody      = GetComponent <Rigidbody>();
        particleManager      = GetComponent <ParticleManager>();
        attackSystem         = GetComponent <AttackSystem>();
        gravity              = GetComponent <Gravity>();
        damageCollider       = GetComponent <CapsuleCollider>();
        objectPoolManager    = GetComponent <ObjectPoolManager>();
        getHitComponent      = GetComponent <GetHitComponent>();
        PlayerShader.enabled = false;

        gameStageData    = GameFacade.GetInstance().gameStageData;
        playerController = GameFacade.GetInstance().playerController;
        playerParameter  = gameStageData.CurPlayerStageData.playerData.playerParameter;
        playerData       = gameStageData.CurPlayerStageData.playerData;

        floorMask = LayerMask.GetMask("Floor");

        playerState = PlayerState.Move;
        ForceMove   = false;
        canfall     = true;
        canTriggerFallingCoroutine = true;
        CreateWeapon();
    }
 public void ToAttack(EntityBase target, string attackName)
 {
     //In the end, the attackStat multiplied by the multiplier and rounded by int
     Debug.Log("DAMAGE : " + (Battlefield.turnList[0].attack * DamageCalculation.CalculateMultiplier(target, dataManager.GetAttackData(attackName))));
     AttackSystem.Attack((Battlefield.turnList[0].attack * DamageCalculation.CalculateMultiplier(target, dataManager.GetAttackData(attackName))), target);
     Battlefield.nextTurn = true;
 }
Exemple #3
0
    public void returnSpawnUnit(GameObject go, UnitAlliance alliance)
    {
        switch (alliance)
        {
        case UnitAlliance.FriendlyVillager:
            friendlyVillagers.Add(go);
            friendlyUnits.Add(go);
            allUnits.Add(go);
            break;

        case UnitAlliance.FriendlyFighter:
            friendlyFighters.Add(go);
            friendlyUnits.Add(go);
            allUnits.Add(go);
            AttackSystem atk = go.GetComponent <AttackSystem>();
            atk.faction = UnitAlliance.FriendlyFighter;
            break;

        case UnitAlliance.EnemyFighter:
            enemyFighters.Add(go);
            allUnits.Add(go);
            AttackSystem atkE = go.GetComponent <AttackSystem>();
            atkE.faction = UnitAlliance.EnemyFighter;
            break;

        default:
            throw new System.ArgumentOutOfRangeException();
        }
    }
Exemple #4
0
        public void Damage_rolls_within_expected_ranges()
        {
            var  asys       = new AttackSystem();
            bool rolled_min = false;
            bool rolled_max = false;

            for (int i = 0; i < 1000; i++)
            {
                int damage = asys.RollDamage(bfh_impact);
                if (damage == 6)
                {
                    rolled_min = true;
                }
                if (damage == 16)
                {
                    rolled_max = true;
                }
                Assert.That(damage, Is.GreaterThanOrEqualTo(6));
                Assert.That(damage, Is.LessThanOrEqualTo(16));
            }

            // Technically a nondeterministic test, so, technically, evil.
            Assert.That(rolled_min, "the probability of not rolling min in 1000 is 5.8e-13, or odds of 1.7 trillion to one.");
            Assert.That(rolled_max, "the probability of not rolling max in 1000 is 5.8e-13, or odds of 1.7 trillion to one.");
        }
 // Start is called before the first frame update
 void Start()
 {
     healthSystem   = this.GetComponent <HealthSystem>();
     attackSystem   = this.GetComponent <AttackSystem>();
     movementSystem = this.GetComponent <MovementSystem>();
     EventHandler.instance.Subscribe(GameEventType.OnPlayerDeath, PlayerDeath);
     EventHandler.instance.PublishGameEvent(GameEventType.OnPlayerHealthChanged, new string[] { healthSystem.HitPoint.ToString() });
 }
 public void attackUpdate(AttackScript givAtkScript, AttackSystem givAttackSystem)
 {
     if (Time.time > nextAttack)
     {
         attackSprite.transform.localScale = new Vector3(-attackSprite.transform.localScale.x, attackSprite.transform.localScale.y, attackSprite.transform.localScale.z);
         nextAttack = Time.time + givAttackSystem.attackRate;
         attackSprite.SetActive(true);
         StartCoroutine(attackUpdateVisuals(givAtkScript));
     }
 }
Exemple #7
0
    public override void Start()
    {
        base.Start();

        controller   = GetComponent <Controller2D>();
        sprite       = GetComponent <SpriteRenderer>();
        attack       = GetComponent <AttackSystem>();
        gravity      = (2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        jumpVelocity = gravity * timeToJumpApex;
    }
Exemple #8
0
        public void Nature_strikes_neighboring_rot_through_our_hero()
        {
            var    player = BeingCreator.CreateBeing("Suvail");
            var    am     = new AttackMethod("physical.impact.blunt", "1d3 +2");
            var    rot    = new AreaRot();
            Attack attack = new Attack
            {
                Attacker      = player,
                AttackMethod  = am,
                Defender      = rot,
                DefenseMethod = rot.GetDefenseMethod(am)
            };

            RotMap rotMap = new RotMap();
            //...add two neighbor ABs, and one further away
            var nbor_1   = new AreaRot();
            var nbor_2   = new AreaRot();
            var stranger = new AreaRot();

            rotMap.Add(rot, (2, 2));
            rotMap.Add(nbor_1, (2, 3));
            rotMap.Add(nbor_2, (3, 1));
            rotMap.Add(stranger, (8, 2));

            GameState gs = new GameState();
            var       cm = new CompoundMap();

            cm.RotMap = rotMap;
            gs.Map    = cm;

            var asys = new AttackSystem {
                GameState = gs
            };

            SourceMe.InjectProperties(asys);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(0));

            asys.CheckForSpecials(attack);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(4));

            var splashBack = asys.AttackQueue.Dequeue();

            Assert.NotNull(splashBack);

            var newAttack = asys.AttackQueue.Dequeue();

            Assert.That(newAttack.Defender, Is.EqualTo(rot));

            newAttack = asys.AttackQueue.Dequeue();
            Assert.That(newAttack.Defender, Is.EqualTo(nbor_2));
            newAttack = asys.AttackQueue.Dequeue();
            Assert.That(newAttack.Defender, Is.EqualTo(nbor_1));
        }
Exemple #9
0
 private void Awake()
 {
     instance             = this;
     entityList           = GetComponent <EntityList>();
     playerInput          = GetComponent <PlayerInput>();
     movementSystem       = GetComponent <MovementSystem>();
     attackSystem         = GetComponent <AttackSystem>();
     healthSystem         = GetComponent <HealthSystem>();
     musicGeneratorSystem = GetComponentInChildren <MusicGeneratorSystem>();
     Init();
 }
Exemple #10
0
 private void Start()
 {
     settuped                      = false;
     startSettings                 = new NanoSetup.NanoSetupStruct();
     player                        = GetComponent <PlayerController>();
     attackSystem                  = GetComponent <AttackSystem>();
     startSettings.FOV             = 5;
     startSettings.scaleMultiplier = transform.localScale.x;
     startSettings.speedMultiplier = player.speed;
     startSettings.attackRadius    = attackSystem.GetRadious();
     cam = Camera.main;
 }
Exemple #11
0
    // public AudioClip DamageClip;

    private void Awake()
    {
        navMeshAgent      = GetComponent <NavMeshAgent>();
        animator          = GetComponent <Animator>();
        attackSystem      = GetComponent <AttackSystem>();
        objectPoolManager = GetComponent <ObjectPoolManager>();
        getHitComponent   = GetComponent <GetHitComponent>();
        particleManager   = GetComponent <ParticleManager>();
        capsuleCollider   = GetComponent <CapsuleCollider>();
        enemyInfo         = enemyData.enemyInfo;
        CreatAttackDisInfoCollection();
    }
Exemple #12
0
        [TestCase(9, "sausage", 4)]  //0.2: would be nice if this broke, to rule out typos.
        public void Default_resistance_when_type_has_no_match(int initial, string type, int expected)
        {
            var asys = new AttackSystem();
            List <AttackDamage> damages = new List <AttackDamage>
            {
                new AttackDamage(initial, type),
            };

            var out_dmgs = asys.ResistDamages(damages, ring_armor);  //  default for ring is 1/2 ..5

            Assert.That(out_dmgs.First().Current, Is.EqualTo(expected));
        }
Exemple #13
0
 /// <summary>
 /// 初始化
 /// </summary>
 private void Initialize()
 {
     //管理类单例
     m_manage      = UIManage.Instance;
     m_SceneManage = SceneStateController.Instance;
     //系统
     uiEvent      = new UIEventSystem(this);
     stageSystem  = new StageSystem(this);
     cardManage   = new CardManageSystem(this);
     attackSystem = new AttackSystem(this);
     //其他
     serialize       = new Serialize(this);
     deserialization = Deserialization.Instance;
 }
Exemple #14
0
    // Update is called once per frame
    void Update()
    {
        if (!hasAuthority)
        {
            return;
        }
        AttackSystem atk = GetComponent <AttackSystem>();

        if (target != null)
        {
            if (Vector2.Distance(target.transform.position, transform.position) < 3)
            {
                print("attack");
                cooldown           = 5f;
                movement.direction = Vector2.zero;

                Cmds.i.CmdPerformAttack(gameObject, atk.IsInWindup());
                movement.direction = Vector2.zero;
            }
            else
            {
                movement.direction = target.position - transform.position;
                movement.direction.Normalize();
            }
        }
        else
        {
            if (atk.faction == UnitAlliance.EnemyFighter)
            {
                var players = GameObject.FindGameObjectsWithTag("Player");
                if (players.Length > 0)
                {
                    List <GameObject> targets = new List <GameObject>();
                    targets.AddRange(players);
                    targets.AddRange(UnitManager.i.friendlyFighters);
                    target = targets.Pick().transform;
                }
            }
            else
            {
                if (UnitManager.i.enemyFighters.Count > 0)
                {
                    target = UnitManager.i.enemyFighters.Pick().transform;
                }
            }
        }
    }
Exemple #15
0
        public void Nature_strikes_the_rot_through_our_hero()
        {
            GameState gs = new GameState();
            var       cm = new CompoundMap();

            cm.RotMap = new RotMap();
            gs.Map    = cm;

            var asys = new AttackSystem();

            asys.GameState = gs;
            SourceMe.InjectProperties(asys);

            var    player = BeingCreator.CreateBeing("Suvail");
            var    am     = new AttackMethod("physical.impact.blunt", "1d3 +2");
            var    rot    = new AreaRot();
            Attack attack = new Attack
            {
                Attacker      = player,
                AttackMethod  = am,
                Defender      = rot,
                DefenseMethod = rot.GetDefenseMethod(am)
            };

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(0));

            asys.CheckForSpecials(attack);

            Assert.That(asys.AttackQueue.Count, Is.EqualTo(2));

            var splashBack = asys.AttackQueue.Dequeue();

            Assert.NotNull(splashBack);

            var newAttack = asys.AttackQueue.Dequeue();
            var newAM     = newAttack.AttackMethod;
            var newAE     = newAM.AttackEffects[0];

            Assert.That(newAE.Type, Is.EqualTo("vital.nature.itself"));
            Assert.That(newAttack.Defender, Is.EqualTo(rot));
            Assert.That(newAttack.Attacker, Is.EqualTo(player));
        }
Exemple #16
0
        public void Can_resist_a_set_of_AttackDamages()
        {
            var asys = new AttackSystem();
            List <AttackDamage> damages = new List <AttackDamage>
            {
                new AttackDamage(8, "physical.impact.blunt"),
                new AttackDamage(6, "physical.impact.edge"),
                new AttackDamage(6, "energetic.fire"),
            };

            Assert.That(damages[0].Initial, Is.EqualTo(8));
            Assert.That(damages[0].Current, Is.EqualTo(8), "initial and current begin equal");

            var out_dmgs = asys.ResistDamages(damages, leather_armor).ToList();

            Assert.That(out_dmgs[0].Initial, Is.EqualTo(8), "resistance doesn't alter initial value");

            Assert.That(out_dmgs[0].Current, Is.EqualTo(6), "leather resists blunt damage poorly");
            Assert.That(out_dmgs[1].Current, Is.EqualTo(3), "leather resists other physical damage better");
            Assert.That(out_dmgs[2].Current, Is.EqualTo(2), "leather resists energy damage well");
        }
Exemple #17
0
    // Use this for initialization
    public static void Build(GameObject unit, UnitData unitData)
    {
        //Add body parts from possible selection
        //Maybe add Color list possibilites (Skin color for goblins/humans, charred/bleached bones for skeletons)
        unit.transform.Find("RArm").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.rightArm.Pick();
        unit.transform.Find("LArm").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.leftArm.Pick();
        unit.transform.Find("Body").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.body.Pick();
        unit.transform.Find("Head").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.head.Pick();
        unit.transform.Find("LLeg").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.leftLeg.Pick();
        unit.transform.Find("RLeg").GetComponent <SpriteRenderer>().sprite = unitData.unitSpriteSet.rightLeg.Pick();

        //Add the animation set for the unit
        if (unitData.unitAnimator != null)
        {
            Animator anim = unit.AddComponent <Animator>();
            anim.runtimeAnimatorController = unitData.unitAnimator;
        }

        //Socket the Weapon prefab to the Right Arm
        if (unitData.weapon.Length > 0)
        {
            GameObject weapon = GameObject.Instantiate(unitData.weapon.Pick());
            weapon.transform.SetParent(unit.transform.Find("RArm"));
            weapon.transform.localPosition = Vector3.zero;
            weapon.transform.localScale    = Vector3.one;
        }

        //Modify combat script stats from here
        AttackSystem atkSys = unit.transform.parent.GetComponent <AttackSystem>();

        if (atkSys != null)
        {
            atkSys.health  = unitData.health;
            atkSys.atkRate = unitData.attackRateMult;
            atkSys.atkMult = unitData.dmgMult;
            atkSys.defMult = unitData.defMult;
        }
    }
    public void GenerateAttack(List <string> attackList)
    {
        DumbFunction <int, int> .DestroyAllChild(transform);

        foreach (string attackName in attackList)
        {
            AttackData attackData = dataManager.GetAttackData(attackName);
            attackButtonText.text = attackName;
            switch (attackData.attackType)
            {
            case 0:
                Instantiate(attackButton, transform).onClick.AddListener(delegate {
                    Debug.Log("ENTERING SINGLE TARGET ATTACK");
                    GenerateEnemy(AttackSystem.EnemyList(Battlefield.turnList), attackName);
                });
                Debug.Log("Single target generated");
                break;

            case 1:
                Instantiate(attackButton, transform).onClick.AddListener(delegate {
                    Debug.Log("ENTERING ALL ROUND ATTACK");
                    foreach (EntityBase target in AttackSystem.EnemyList(Battlefield.turnList).Values) // the turnlist will be changed with the enemyList in the future
                    {
                        ToAttack(target, attackName);                                                  // attack all
                    }
                });
                Debug.Log("All attack target generated");
                break;

            case -1:
                Debug.Log("Invalid attack");
                break;
            }
        }
        AdjustButton(transform);
        Debug.Log("Attack Generation done");
    }
Exemple #19
0
    private void Awake()
    {
        PlayerList   = new List <BasicEntity> ();
        EnemyList    = new List <BasicEntity> ();
        basicSystems = new List <BasicSystem> ();

        //找到对应game object动态加载实体

        ////动态加载模块
        //AttackComponent attackComponent = GameObject.Find ("HealthyCube").AddComponent<AttackComponent> ();
        ////必须执行,依次加载组件的初始化,动态加载的组件会在组件管理器中注册
        //attackComponent.Init (ComponentType.Attack, cube);

        ////必须执行,最后初始化实体,它会把直接挂载在game object上的组件一起注册
        //cube.Init ();

        //PlayerList.Add (cube);

        DeadSystem deadSystem = new DeadSystem();

        deadSystem.M_LinkedType = ComponentType.Dead;

        HideSystem hideSystem = new HideSystem();

        hideSystem.M_LinkedType = ComponentType.Hide;

        MoveSystem moveSystem = new MoveSystem();

        moveSystem.M_LinkedType = ComponentType.Move;

        AttackSystem attackSystem = new AttackSystem();

        attackSystem.M_LinkedType = ComponentType.Attack;

        InputSystem inputSystem = new InputSystem();

        inputSystem.M_LinkedType = ComponentType.Input;

        UISystem uiSystem = new UISystem();

        uiSystem.M_LinkedType = ComponentType.UI;

        CheerUpSystem cheerUpSystem = new CheerUpSystem();

        cheerUpSystem.M_LinkedType = ComponentType.CheerUp;

        MonitorSystem monitorSystem = new MonitorSystem();

        monitorSystem.M_LinkedType = ComponentType.Monitor;

        KnockSystem knockSystem = new KnockSystem();

        knockSystem.M_LinkedType = ComponentType.Knock;

        ItemSystem itemSystem = new ItemSystem();

        itemSystem.M_LinkedType = ComponentType.Item;

        AISystem aiSystem = new AISystem();

        aiSystem.M_LinkedType = ComponentType.AI;

        basicSystems.Add(deadSystem);
        basicSystems.Add(hideSystem);
        basicSystems.Add(moveSystem);
        basicSystems.Add(attackSystem);
        basicSystems.Add(inputSystem);
        basicSystems.Add(uiSystem);
        basicSystems.Add(cheerUpSystem);
        basicSystems.Add(monitorSystem);
        basicSystems.Add(knockSystem);
        basicSystems.Add(itemSystem);
        basicSystems.Add(aiSystem);
    }
Exemple #20
0
 /// <summary>
 /// Called after end of backswing.
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 public virtual void OnComplete(AttackSystem attacker)
 {
 }
Exemple #21
0
 /// <summary>
 /// Called after all OnHit or OnMiss events, at beginning of backswing.
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 public virtual void OnAfterHit(AttackSystem attacker)
 {
 }
Exemple #22
0
 /// <summary>
 /// Called if no character was hit.
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 public virtual void OnMiss(AttackSystem attacker)
 {
 }
Exemple #23
0
 /// <summary>
 /// Called for each character that is hit.
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 /// <param name="hit">Character that is hit.</param>
 /// <param name="numHit">Which number hit was the object (0 to totalHit).</param>
 /// <param name="totalHit">Number of total objects that are going to be hit.</param>
 public virtual void OnHit(AttackSystem attacker, GameObject hit, int numHit, int totalHit)
 {
 }
Exemple #24
0
 /// <summary>
 /// Called after windup period before any OnHit calls, attack is not guaranteed to hit.
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 /// <param name="totalHit">Number of total objects that are going to be hit.</param>
 public virtual void OnBeforeHit(AttackSystem attacker, int totalHit)
 {
 }
Exemple #25
0
 /// <summary>
 /// Called at beginning of attack.
 ///
 /// </summary>
 /// <param name="attacker">Attacker.</param>
 public virtual void OnSwing(AttackSystem attacker)
 {
 }
Exemple #26
0
    protected override void OnCreate()
    {
        inputSystem     = World.GetOrCreateSystem <InputSystem>();
        selectionSystem = World.GetOrCreateSystem <SelectionSystem>();

        lockstepSystemGroup = World.GetOrCreateSystem <LockstepSystemGroup>();
        lockstepSystemGroup.AddSystemToUpdateList(World.GetOrCreateSystem <CommandExecutionSystem>());
        lockstepSystemGroup.AddSystemToUpdateList(World.GetOrCreateSystem <VolatileCommandSystem>());
        lockstepSystemGroup.AddSystemToUpdateList(World.GetOrCreateSystem <CommandableSafetySystem>());

        blockMovementSystem = World.GetOrCreateSystem <BlockMovementSystem>();

        onGroupCheckSystem = World.GetOrCreateSystem <OnGroupCheckSystem>();

        updateReachableHexListSystem = World.GetOrCreateSystem <UpdateReachableHexListSystem>();

        resourceSourceManagerSystem = World.GetOrCreateSystem <ResourceSourceManagerSystem>();
        triggerGatherSystem         = World.GetOrCreateSystem <TriggerGatherSystem>();

        dropPointSystem = World.GetOrCreateSystem <DropPointSystem>();

        triggerUpdateResBufferSystem = World.GetOrCreateSystem <TriggerUpdateResBufferSystem>();
        updateResourceBufferSystem   = World.GetOrCreateSystem <UpdateResourceBufferSystem>();


        updateOcupationMapSystem = World.GetOrCreateSystem <UpdateOcupationMapSystem>();
        updateDestinationSystem  = World.GetOrCreateSystem <UpdateDestinationSystem>();

        sightSystem = World.GetOrCreateSystem <SightSystem>();

        pathRefreshSystem     = World.GetOrCreateSystem <PathRefreshSystem>();
        pathFindingSystem     = World.GetOrCreateSystem <PathFindingSystem>();
        pathChangeIndexSystem = World.GetOrCreateSystem <PathChangeIndexSystem>();

        findPosibleTargetsSystem = World.GetOrCreateSystem <FindPosibleTargetsSystem>();
        findActionTargetSystem   = World.GetOrCreateSystem <FindActionTargetSystem>();

        findMovementTargetSystem = World.GetOrCreateSystem <FindMovementTargetSystem>();
        steeringSystem           = World.GetOrCreateSystem <SteeringSystem>();
        translationSystem        = World.GetOrCreateSystem <TranslationSystem>();
        movementFinisherSystem   = World.GetOrCreateSystem <MovementFinisherSystem>();



        collisionSystem = World.GetOrCreateSystem <CollisionSystem>();
        directionSystem = World.GetOrCreateSystem <DirectionSystem>();


        startActSystem = World.GetOrCreateSystem <StartActSystem>();
        removeReceivingActComponentsSystem = World.GetOrCreateSystem <RemoveReceivingActComponentsSystem>();
        initReceivingActComponentsSystem   = World.GetOrCreateSystem <InitReceivingActComponentsSystem>();
        attackSystem                = World.GetOrCreateSystem <AttackSystem>();
        receiveDamageSystem         = World.GetOrCreateSystem <ReceiveDamageSystem>();
        gatherSystem                = World.GetOrCreateSystem <GatherSystem>();
        extractResourceSystem       = World.GetOrCreateSystem <ExtractResourceSystem>();
        updateGathererAmmountSystem = World.GetOrCreateSystem <UpdateGathererAmmountSystem>();
        endActionSystem             = World.GetOrCreateSystem <EndActionSystem>();


        resourceSystem = World.GetOrCreateSystem <ResourceSystem>();


        deathSystem = World.GetOrCreateSystem <DeathSystem>();
        //simulationSystemGroup = World.GetOrCreateSystem<SimulationSystemGroup>();
        //simulationSystemGroup.AddSystemToUpdateList(World.GetOrCreateSystem<PathFindingSystem>());
        //simulationSystemGroup.AddSystemToUpdateList(World.GetOrCreateSystem<PathFollowSystem>());

        //lateSimulationSystemGroup = World.GetOrCreateSystem<LateSimulationSystemGroup>();

        //applicationSystemGroup = World.GetOrCreateSystem<ApplicationSystemGroup>();
    }
Exemple #27
0
    // Update is called once per frame
    void Update()
    {
        if (health <= 0)
        {
            if (!isLocalPlayer)
            {
                UnitManager.i.DestroyUnit(this.gameObject);
            }
            else
            {
                transform.position = Vector3.zero;
                FightManager.i.inCombatPlayers--;
                CmdSetHeatlth(1000, GetComponent <NetworkIdentity>().netId);
            }
        }
        //Doing a windup
        if (IsInWindup())
        {
            windupTime -= Time.deltaTime * atkRate;
            //Is windup finished (attack being done now)
            if (windupTime <= 0)
            {
                WeaponCollision   wc         = GetComponentInChildren <WeaponCollision>();
                List <GameObject> objectsHit = new List <GameObject>();
                foreach (GameObject go in wc.currentCollisions)
                {
                    objectsHit.Add(go);
                }

                int objectsHitCount = objectsHit.Count;

                WeaponAttack chainAttack = weaponObject.chainAttack[attackStage];
                foreach (SwingEffect swing in chainAttack.swingEffects)
                {
                    swing.OnBeforeHit(this, objectsHitCount);
                }

                foreach (SwingEffect swing in chainAttack.swingEffects)
                {
                    if (objectsHit.Count == 0)
                    {
                        swing.OnMiss(this);
                    }
                    else
                    {
                        for (int i = 0; i < objectsHitCount && i < chainAttack.cleave; i++)
                        {
                            GameObject obj = objectsHit[i];
                            swing.OnHit(this, obj, i, objectsHitCount);
                            //Play random hit sound

                            //Apply base damage
                            if (obj == null)
                            {
                                break;
                            }
                            AttackSystem at = obj.GetComponent <AttackSystem>();
                            if (at != null && at.faction != faction)
                            {
                                at.CmdInflictDamage((int)(20 * atkMult / at.defMult), at.GetComponent <NetworkIdentity>().netId);
                            }
                        }
                    }
                }
            }
        }
        //Windup was completed
        else
        {
            //Doing backswing
            if (IsInBackswing())
            {
                backswingTime -= Time.deltaTime * atkRate;
                //backswing just finished
                if (backswingTime <= 0)
                {
                    WeaponAttack chainAttack = weaponObject.chainAttack[attackStage];
                    foreach (SwingEffect swing in chainAttack.swingEffects)
                    {
                        swing.OnComplete(this);
                    }
                    attackStage = -1;
                }
            }
            //Backswing was completed
            //E.g. Doing nothing currently
            else
            {
                if (bufferedAttack >= 0)
                {
                    BeginAttack();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.P) && isLocalPlayer)
        {
            print("isLocalplayer");
            CmdAttackMessage(IsInWindup());
        }
    }