Beispiel #1
0
    private void Awake()
    {
        m_rigidbody2D               = this.GetComponent <Rigidbody2D>();
        m_animFuntion               = this.transform.Find("PlayerSpineSprite").GetComponent <PlayerAnimFuntion>();
        m_attackCollider            = NormalAttackEffect.GetComponent <AttackCollider>();
        m_characterMove             = this.GetComponent <CharacterMove>();
        m_playerState               = this.GetComponent <PlayerState>();
        m_playerInput               = this.GetComponent <PlayerInput>();
        m_playerCrowdControlManager = this.GetComponent <PlayerCrowdControlManager>();
        m_randAudioFuntion          = this.GetComponent <PlayerRandAudioFuntion>();
        m_audioFuntion              = this.GetComponent <PlayerAudioFunction>();

        m_bAttacking = false;

        m_NormalAttackDic = new Dictionary <string, AttackInfo>();

        m_NormalAttackDic.Add("attack_1", new AttackInfo(1.0f, new Vector2(2.0f, 3f)));
        m_NormalAttackDic.Add("attack_2", new AttackInfo(1.0f, new Vector2(2.0f, 3f)));
        m_NormalAttackDic.Add("attack_3_1", new AttackInfo(0.5f, new Vector2(2.0f, 5.0f)));
        m_NormalAttackDic.Add("attack_3_2", new AttackInfo(2.0f, new Vector2(2.0f, -10.0f)));
        m_NormalAttackDic.Add("attack_4", new AttackInfo(3.0f, new Vector2(2.0f, 10.0f)));
        m_NormalAttackDic.Add("attack_5", new AttackInfo(4.0f, new Vector2(10.0f, 10.0f)));

        m_NormalAttackDic.Add("air_attack_1", new AttackInfo(1.0f, new Vector2(1f, 12f)));
        m_NormalAttackDic.Add("air_attack_2", new AttackInfo(1.0f, new Vector2(1f, 12f)));
        m_NormalAttackDic.Add("air_attack_3", new AttackInfo(1.0f, new Vector2(1f, 12f)));
        m_NormalAttackDic.Add("air_attack_4", new AttackInfo(1.0f, new Vector2(5f, 12f)));

        m_NormalAttackDic.Add("attack_upper", new AttackInfo(3.0f, new Vector2(1f, 24.0f)));
        m_NormalAttackDic.Add("attack_downsmash", new AttackInfo(4.0f, new Vector2(2f, -25.0f)));
    }
Beispiel #2
0
    private void Awake()
    {
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;

        GameObject[] gameObjects = FindObjectsOfType <GameObject>();

        for (int j = 0; j < gameObjects.Length; ++j)
        {
            ReceiveDamage  receiveDamage  = gameObjects[j].GetComponent <ReceiveDamage>();
            AttackCollider attackCollider = gameObjects[j].GetComponent <AttackCollider>();
            CharacterMove  characterMove  = gameObjects[j].GetComponent <CharacterMove>();

            if (receiveDamage)
            {
                count1++;
            }

            if (attackCollider != null)
            {
                count2++;
            }

            if (characterMove)
            {
                count3++;
            }
        }

        Debug.Log("ReceiveDamage의 갯수: " + count1);
        Debug.Log("AttackCollider의 갯수: " + count2);
        Debug.Log("CharacterMove의 갯수: " + count3);
    }
Beispiel #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (photonView.IsMine)
     {
         if (other.gameObject.CompareTag(Tags.Attack))
         {
             if (attackCollider == null || attackCollider != other.gameObject.GetComponent <AttackCollider>())
             {
                 attackCollider = other.gameObject.GetComponent <AttackCollider>();
             }
             if (damageInterval < 0.0f)
             {
                 damageInterval = 0.5f;
                 if (attackCollider.teamColor != teamColor)
                 {
                     Gorillaization();
                 }
                 else
                 {
                     humanMover.AttackAway(attackCollider.attackerTransform.position);
                     humanAnimator.KnockBackTrigger();
                 }
             }
         }
     }
 }
    protected override void ExecuteActionTailAttack()
    {
        // Check if the tail hit anything
        tailHasHit = parameters.creature.HitSomething();

        parameters.creature.SetAnimatorTrigger(tailAttackTrigger);
        // Get the targets of the attack
        AttackCollider            attackCollider = parameters.creature.GetHitColliderFromDirection();
        List <KillableGridObject> targets        = attackCollider.GetKillList();

        if (targets.Count > 0)
        {
            // Damage each target
            foreach (KillableGridObject target in targets)
            {
                if (target.faction != parameters.creature.faction)
                {
                    target.TakeDamage(parameters.creature.damage);

                    // Apply status effect to targets
                    StatusEffect.ApplyStatusEffect(parameters.creature, target, parameters.scorpionVenom);
                }
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     anFish = gameObject.GetComponent<Animator> () as Animator;
     anStars = (gameObject.GetComponentsInChildren<Animator>() as Animator[])[1];
     attackCollider = gameObject.GetComponent<AttackCollider> () as AttackCollider;
     attack = gameObject.GetComponent<Attack> () as Attack;
     touch = false;
 }
Beispiel #6
0
 void Awake()
 {
     attackCollider = GetComponent <AttackCollider>();
     if (!attackCollider)
     {
         attackCollider = GetComponentInChildren <AttackCollider>();
     }
 }
Beispiel #7
0
 private void Awake()
 {
     m_attackcollider  = this.GetComponentInChildren <AttackCollider>();
     m_animator        = this.GetComponentInChildren <Animator>();
     m_bAttacking      = false;
     m_normalAttackDic = new Dictionary <string, AttackInfo>();
     m_normalAttackDic.Add("Attack_1", new AttackInfo(1.0f, new Vector2(2.0f, 10.0f)));
     m_normalAttackDic.Add("Attack_2", new AttackInfo(1.0f, new Vector2(3.0f, 10.0f)));
 }
Beispiel #8
0
 private void DEBUGShowCollider(bool enabled)
 {
     // DEBUG
     // Show collider if timer is running
     MeshRenderer[] mRenders = AttackCollider.GetComponentsInParent <MeshRenderer>();
     if (mRenders.Length > 0)
     {
         mRenders[0].enabled = enabled;
     }
 }
    public override void InitSkill(PlayerAnimFuntion _animFuntion, GameObject _playerObject)
    {
        base.InitSkill(_animFuntion, _playerObject);

        m_meshRenderer      = this.GetComponent <MeshRenderer>();
        m_attackCollider    = this.GetComponent <AttackCollider>();
        m_effectAnimFuntion = this.GetComponent <EffectAnimFuntion>();

        m_attackCollider.iCollisionSize = collisionSize;
        m_attackCollider.SetDamageColliderInfo(damageRatio * level, "Monster", damageForce);
    }
Beispiel #10
0
 public override bool Attack()
 {
     if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
     {
         anim.SetTrigger("Attack");
         AttackCollider ac = Instantiate(ac_prefab, head.transform.position, head.transform.rotation);
         ac.Initialise(damage, weapon_reach, is_owned_by_player, attack_width);
         return(true);
     }
     return(false);
 }
Beispiel #11
0
    private void Awake()
    {
        m_attackcollider  = this.GetComponentInChildren <AttackCollider>();
        m_bAttacking      = false;
        m_normalAttackDic = new Dictionary <string, AttackInfo>();
        m_normalAttackDic.Add(ATTACK_KINDS.ATTACK_1.ToString(), new AttackInfo(1.0f, new Vector2(2.0f, 10.0f)));
        m_normalAttackDic.Add(ATTACK_KINDS.ATTACK_2.ToString(), new AttackInfo(1.0f, new Vector2(3.0f, 10.0f)));

        m_currentDelay = 0;

        InitMonstInfo();
    }
Beispiel #12
0
    void Start()
    {
        float xLimit = Camera.main.aspect * Camera.main.orthographicSize - transform.localScale.x / 2f;
        float yLimit = Camera.main.orthographicSize - transform.localScale.y / 2f;

        xRange = new Vector2(-xLimit, xLimit);
        yRange = new Vector2(-yLimit, yLimit);

        velocity       = Vector2.zero;
        isDashing      = false;
        attackCollider = transform.GetChild(0).gameObject.GetComponent <AttackCollider>();
    }
 public void AddAttackCollider(string name, List <List <Rectangle> > rectangleFrames)
 {
     for (var i = 0; i < rectangleFrames.Count; i++)
     {
         for (var j = 0; j < rectangleFrames[i].Count; j++)
         {
             var collider = new AttackCollider(rectangleFrames[i][j].X, rectangleFrames[i][j].Y, rectangleFrames[i][j].Width, rectangleFrames[i][j].Height);
             entity.addComponent(collider);
             _animations[name].Frames[i].AttackColliders.Add(collider);
         }
     }
 }
Beispiel #14
0
    public static int CalculateHitDirection(AttackCollider c, AttackInfo a, double hitX)
    {
        var reference = a.directionReference[0];
        var type      = a.directionReference[1];
        var direction = 0;
        var refX      = 0.0;

        switch (reference)
        {
        case 0:       // self  (creature or effect)
        {
            direction = c.direction;
            refX      = c.center.x;
            break;
        }

        case 1:       // created (source when attack collider created)
        {
            direction = c.startDirection;
            refX      = c.center.x;
            break;
        }

        case 2:       // source (source when hited)
        {
            direction = c.creature ? c.creature.direction.ToInt() : 0;
            refX      = c.creature ? c.creature.x : c.center.x;
            break;
        }

        default:  return(0);     // none
        }

        if (direction == 0 || type == 1)
        {
            return(direction);
        }
        if (type == 0)
        {
            return(direction * -1);
        }
        if (type == 2)
        {
            return(refX <hitX ? -1 : refX> hitX ? 1 : 0);
        }
        if (type == 3)
        {
            return(refX <hitX ? 1 : refX> hitX ? -1 : 0);
        }

        return(direction * -1);
    }
Beispiel #15
0
    private void Awake()
    {
        if (rendererObject == null)
        {
            Debug.Log("WeaponBehaviour :: 렌더링 하는 무기 오브젝트가 존재하지 않습니다. 인스펙터를 확인해주세요.");
            return;
        }

        player         = transform.root.GetComponent <PlayerBehaviour>();
        spriteRenderer = rendererObject.GetComponent <SpriteRenderer>();
        ani            = rendererObject.GetComponent <Animator>();
        attackCollider = GetComponentInChildren <AttackCollider>();
    }
Beispiel #16
0
    void OnTriggerEnter(Collider _other)
    {
        AttackCollider attack = _other.GetComponent <AttackCollider>();

        if (attack != null)
        {
            // TODO: Probably store these values in the attack itself to avoid having to reference the player
            float attackAmt = Random.Range(0f, attack.Player.MaxAttack);
            float attackDmg = Random.Range(0f, attack.Player.MaxDamage);
            //Debug.Log("Attack: " + attackAmt);

            // Evaluate attack power against all HP (Guard) pools and subtract accordingly
            // Any HP pool that is hit by an attack has its recharge rate reset to zero
            if (attackAmt <= HP.CurrentBlock)
            {
                //Debug.Log("Block: " + attackDmg);
                HP.CurrentBlock           -= attackDmg;
                HP.BlockRechargeMultiplier = 0f;
                return;
            }
            attackAmt -= HP.CurrentBlock;
            if (attackAmt <= HP.CurrentDodge)
            {
                //Debug.Log("Dodge: " + attackDmg);
                HP.CurrentDodge           -= attackDmg;
                HP.DodgeRechargeMultiplier = 0f;
                return;
            }
            attackAmt -= HP.CurrentDodge;
            if (attackAmt <= HP.CurrentParry)
            {
                //Debug.Log("Parry: " + attackDmg);
                HP.CurrentParry           -= attackDmg;
                HP.ParryRechargeMultiplier = 0f;
                return;
            }
            attackAmt -= HP.CurrentParry;

            // Evaluate remaining attack power against Armor
            float armorBypassChance = attackAmt / (attackAmt + HP.CurrentArmor);
            if (Random.Range(0f, 1f) >= armorBypassChance)
            {
                //Debug.Log("Armor");
                return;
            }

            // Subtract HP
            //Debug.Log("Damage: " + attackDmg);
            HP.CurrentHealth -= attackDmg;
        }
    }
        protected override IEnumerator InnerDoAttack(int id, CombatSystem ownerCombatSystem, Transform target)
        {
            if (target == null)
            {
                yield break;
            }

            while (!AnimationStates[id])
            {
                yield return(null);
            }

            GameObject projectile = PoolersManager.Instance.TryGetPooler(data.ProjectilePrefab).GetPooledObject(data.DestroyTime);

            projectile.transform.position = ownerCombatSystem.ProjectileAnchor.position;
            projectile.transform.rotation = ownerCombatSystem.ProjectileAnchor.rotation;

            AttackCollider projectileAttackCollider = projectile.GetComponentInChildren <AttackCollider>();

            projectileAttackCollider.Initialize(id, data.ColliderRadius, this, ownerCombatSystem.transform.root, ownerCombatSystem);
            projectileAttackCollider.SetRadius(data.ColliderRadius);

            ProjectileMovement projectileMovement = projectile.GetComponent <ProjectileMovement>();

            projectileMovement.Launch(target, ownerCombatSystem.ProjectileAnchor, data.MinDistance, data.MaxDistance, data.ProjectileSpeed);

            float timer = 0.0f;

            while (timer <= data.DestroyTime)
            {
                if (HasHit[id])
                {
                    projectileMovement.Stop();

                    if (!data.SplashDamage)
                    {
                        yield break;
                    }

                    projectileAttackCollider.SetRadius(data.SplashDamageRadius);

                    yield return(new WaitForSeconds(data.SplashDamageTime));

                    yield break;
                }

                timer += Time.deltaTime;
                yield return(null);
            }
        }
Beispiel #18
0
    protected override void Start()
    {
        m_monsterKind     = MONSTER_KINDS.BOSS_LARVO;
        m_patternPlaying  = false;
        m_attackcollider  = this.GetComponentInChildren <AttackCollider>();
        m_bAttacking      = false;
        m_normalAttackDic = new Dictionary <string, AttackInfo>();
        m_normalAttackDic.Add(ATTACK_KINDS.ATTACK_1.ToString(), new AttackInfo(1.0f, new Vector2(2.0f, 1.0f)));
        //m_normalAttackDic.Add(ATTACK_KINDS.ATTACK_2.ToString(), new AttackInfo(1.0f, new Vector2(3.0f, 10.0f)));

        m_currentDelay = 0;

        InitMonstInfo();
        base.Start();
    }
Beispiel #19
0
    public override void initialize()
    {
        attackType   = AttackType.Combo;
        eventHandler = GameManager.playerAnimator.gameObject.GetComponent <AnimationEventBroadcast>();
        eventHandler.subscribe(this);

        stick = GameManager.player.GetComponent <PlayerController>().weapon.GetComponentInChildren <Collider>();
        leg   = GameManager.player.GetComponent <PlayerController> ().playerLegObject.GetComponent <Collider> ();
        fist  = GameManager.player.GetComponent <PlayerController> ().playerFistObject.GetComponent <Collider> ();

        attackColliderStick = GameManager.player.GetComponent <PlayerController>().weapon.GetComponentInChildren <AttackCollider>();
        attackColliderLeg   = GameManager.player.GetComponent <PlayerController> ().playerLegObject.GetComponent <AttackCollider> ();
        attackColliderFist  = GameManager.player.GetComponent <PlayerController> ().playerFistObject.GetComponent <AttackCollider> ();
        weaponEffects       = GameManager.player.GetComponent <PlayerController>().weapon.GetComponentInChildren <Xft.XWeaponTrail>();
        slashController     = GameManager.player.GetComponent <PlayerController>().weapon.GetComponentInChildren <SlashController>();
        enemiesHit          = new List <GameObject> (0);
        //weaponEffects.StopSmoothly(0.1f);
    }
Beispiel #20
0
        protected override IEnumerator InnerDoAttack(int id, CombatSystem ownerCombatSystem, Transform target)
        {
            while (!AnimationStates[id])
            {
                yield return(null);
            }

            AttackCollider attackCollider = _attackGameObjects[id].GetComponentInChildren <AttackCollider>();

            attackCollider.Initialize(id, data.ColliderRadius, this, ownerCombatSystem.transform.root, ownerCombatSystem);

            _attackGameObjects[id].transform.position = ownerCombatSystem.transform.position + (ownerCombatSystem.transform.forward * data.Range);

            while (AnimationStates[id])
            {
                yield return(null);

                if (!HasHit[id])
                {
                    continue;
                }

                if (!data.CanDamageMultipleUnits)
                {
                    yield break;
                }

                if (!data.SplashDamage)
                {
                    continue;
                }

                float timer = 0f;
                _attackGameObjects[id].GetComponentInChildren <AttackCollider>().SetRadius(data.SplashDamageRadius);

                while (timer < data.SplashDamageTime)
                {
                    yield return(null);

                    timer += Time.deltaTime;
                }
            }
        }
Beispiel #21
0
        public void SetupDefault()
        {
            // Attack collider Range
            attackColliderObj = champion.transform.Find("AttackCollider").gameObject;
            attackColliderObj.transform.localScale = new Vector3(range, 0.1f, range);
            attackCollider = attackColliderObj.GetComponent <AttackCollider>();
            ActiveAttackCollider(false);
            // Hp bar
            hpBarObj = champion.transform.Find("HpBar").gameObject;
            hpBar    = hpBarObj.transform.Find("ForeImg").GetComponent <Image>();
            VisibleHpBar(false);
            // bool
            isFightOk = false;
            isDeath   = false;

            // particle
            wizzardEffect = champion.transform.GetComponentInChildren <ParticleSystem>();
            levelUp       = champion.transform.Find("character/Levelup Effect").GetComponent <ParticleSystem>();
        }
Beispiel #22
0
    private void Start()
    {
        // いろいろ取得
        gorillaMover    = GetComponent <GorillaMover>();
        mouseLooker     = GetComponent <MouseLooker>();
        gorillaAnimator = GetComponent <GorillaAnimator>();
        humanGrabing    = GetComponent <HumanGrabing>();
        // 移動のスタート関数
        gorillaMover.StartM();
        if (photonView.IsMine)
        {
            // マウス移動のスクリプトはカメラの奪い合いが発生するので自分のだけ処理
            mouseLooker.StartM();
        }
        Resources.UnloadUnusedAssets();
        camTr       = Camera.main.transform;
        nameLabelTr = transform.Find("NameLabel");
        nameLabelTr.GetComponent <TextMesh>().text = photonView.Owner.NickName;

        if (photonView.Owner.CustomProperties[Hashes.TeamColor] is int teamColor)
        {
            SetTeam((TeamColor)teamColor);
        }
        if (photonView.Owner.CustomProperties[Hashes.ID] is int id)
        {
            this.id = id;
        }
        AttackCollider mineAttackCollider = attackColliderObj.GetComponent <AttackCollider>();

        mineAttackCollider.actorNumber       = photonView.OwnerActorNr;
        mineAttackCollider.teamColor         = this.teamColor;
        mineAttackCollider.attackerTransform = transform;
        attackColliderObj.SetActive(false);

        if (PhotonNetwork.IsMasterClient)
        {
            GameObject.FindWithTag(Tags.GameManager).GetComponent <MyGameManager>().UpdateHumanCount(this.teamColor);
        }
    }
Beispiel #23
0
 private void OnTriggerEnter(Collider other)
 {
     if (photonView.IsMine)
     {
         if (t < 1.0f)
         {
             return;
         }
         if (other.gameObject.CompareTag(Tags.Attack))
         {
             if (attackCollider == null || attackCollider != other.gameObject.GetComponent <AttackCollider>())
             {
                 attackCollider = other.gameObject.GetComponent <AttackCollider>();
             }
             if (attackCollider.actorNumber != photonView.OwnerActorNr)
             {
                 gorillaMover.AttackAway(attackCollider.attackerTransform.position);
                 gorillaAnimator.KnockBackTrigger();
             }
         }
     }
 }
Beispiel #24
0
    // Use this for initialization
    new void Start()
    {
        enemyType   = EnemyType.getType(spawnID);
        attackTimer = 0.0f;
        //gm = FindObjectOfType<GameManager> ();
        //PathRequestManager.RequestPath(this, transform.position, target.transform.position, OnPathFound);
        pathFindTimer = pathRefreshTime;

        AttackCollider acLoad = Resources.Load("Attributes/AttackCollider", typeof(AttackCollider)) as AttackCollider;

        ac = (AttackCollider)Instantiate(acLoad);
        ac.setRadius(transform.GetComponent <CircleCollider2D>().radius);
        ac.owner              = this;
        ac.transform.parent   = transform;
        ac.transform.position = transform.position;

        stats = (AttributesZ)Instantiate(gm.AttributeZ);
        stats.setOwner(this);
        stats.mode = "Idle";

        //Add items to enemy Inventory
        enemyInventory = new Dictionary <string, int> ();
        enemyInventory.Add("cloth", 0);
        enemyInventory.Add("wood", 0);
        enemyInventory.Add("metal", 0);
        int clothNum = (int)Random.Range(0.0f, 3.0f);
        int woodNum  = (int)Random.Range(0.0f, 2.0f);
        int metalNum = (int)Random.Range(0.0f, 2.0f);

        enemyInventory ["cloth"] = clothNum;
        enemyInventory ["wood"]  = woodNum;
        enemyInventory ["metal"] = metalNum;
        //Debug.Log("EnemyInventory: " + "cloth: " + enemyInventory ["cloth"] + " | wood: " + enemyInventory ["wood"] + " | metal: " + enemyInventory ["metal"]);
        itemCloth = Resources.Load("Materials/cloth", typeof(Item)) as Item;
        itemWood  = Resources.Load("Materials/wood", typeof(Item)) as Item;
        itemMetal = Resources.Load("Materials/metal", typeof(Item)) as Item;
    }
Beispiel #25
0
    // =====================================================
    // | States
    // =====================================================

    protected override void ExecuteActionAttack()
    {
        // Get the targets of the attack
        AttackCollider            attackCollider = parameters.creature.GetHitColliderFromDirection();
        List <KillableGridObject> targets        = attackCollider.GetKillList();

        if (targets.Count > 0)
        {
            // Puts attack on cooldown
            canAttack = false;

            // Damage each target
            foreach (KillableGridObject target in targets)
            {
                if (target.faction != parameters.creature.faction)
                {
                    target.TakeDamage(parameters.creature.damage);

                    // Apply status effect to targets
                    StatusEffect.ApplyStatusEffect(parameters.creature, target, parameters.spinStun);
                }
            }
        }
    }
Beispiel #26
0
    protected override bool CanAttack()
    {
        // Check cooldown
        AttackCollider edgeTrigger = GetHitColliderFromDirection(direction);

        List <KillableGridObject> killList = edgeTrigger.GetKillList();

        // Check if there is anything to kill
        if (killList.Count > 0)
        {
            // Check if any of the killables are an enemy
            foreach (KillableGridObject target in killList)
            {
                if (target.faction != this.faction)
                {
                    // Rotate in the direction of the target monster is attacking
                    Rotate(Globals.VectorsToDirection(transform.position, target.transform.position));
                    return(true);
                }
            }
        }

        return(false);
    }
    protected override bool CanAttack()
    {
        AttackCollider attackCollider = GetHitColliderFromDirection(direction);

        List <KillableGridObject> killList = attackCollider.GetKillList();

        if (killList.Count > 0)
        {
            // Check if the killable is an enemy
            foreach (KillableGridObject tar in killList)
            {
                if (tar.faction != this.faction)
                {
                    return(true);
                }
            }

            return(false);
        }
        else
        {
            return(false);
        }
    }
Beispiel #28
0
 // Use this for initialization
 void Start()
 {
     attColScrpt = Player.GetComponent <AttackCollider>();
     attackColl  = Attack_Collider.GetComponent <BoxCollider2D>();
     movescrpt   = Player.GetComponent <MoveScript3>();
 }
Beispiel #29
0
 void Start()
 {
     anim   = GetComponentInChildren <Animator>();
     attack = GetComponentInChildren <AttackCollider>();
 }
    public override void initialize()
    {
        attackType = AttackType.Combo;
        eventHandler = GameManager.playerAnimator.gameObject.GetComponent<AnimationEventBroadcast>();
        eventHandler.subscribe(this);

        stick = GameManager.player.GetComponent<PlayerController>().weapon.GetComponentInChildren<Collider>();
        leg = GameManager.player.GetComponent<PlayerController> ().playerLegObject.GetComponent<Collider> ();
        fist = GameManager.player.GetComponent<PlayerController> ().playerFistObject.GetComponent<Collider> ();

        attackColliderStick = GameManager.player.GetComponent<PlayerController>().weapon.GetComponentInChildren<AttackCollider>();
        attackColliderLeg = GameManager.player.GetComponent<PlayerController> ().playerLegObject.GetComponent<AttackCollider> ();
        attackColliderFist = GameManager.player.GetComponent<PlayerController> ().playerFistObject.GetComponent<AttackCollider> ();
        weaponEffects = GameManager.player.GetComponent<PlayerController>().weapon.GetComponentInChildren<Xft.XWeaponTrail>();
        slashController = GameManager.player.GetComponent<PlayerController>().weapon.GetComponentInChildren<SlashController>();
        enemiesHit = new List<GameObject> (0);
        //weaponEffects.StopSmoothly(0.1f);
    }
Beispiel #31
0
    public void OnHit(AttackCollider c, AttackInfo a, int t)
    {
        if (null == m_creature)
        {
            return;
        }
        var alive = !m_creature.isDead;

        var ts      = t == byte.MaxValue ? AttackInfo.hitProtectTrans : a.targetStates[t];
        var cc      = c.creature;
        var ss      = c.currentState;
        var passive = ss.info.ignoreTough || (!m_creature.tough || a.breakToughLevel > m_creature.toughLevel) || m_creature.weak && a.fromBullet;  // can we enter passive state ?
        var toState = -1;

        if (passive)
        {
            var pt         = 0L;
            var breakTough = m_creature.tough && (ss.info.ignoreTough || a.breakToughLevel > m_creature.toughLevel || cc.breakToughLevel > m_creature.toughLevel);
            var isCatch    = ss.info.catchState > 0;
            if (isCatch)
            {
                pt = pt.BitMask(StateMachine.PASSIVE_CATCH, true);
            }
            if (breakTough)
            {
                pt = pt.BitMask(StateMachine.PASSIVE_TOUGH, true);
            }
            if (a.fromBullet && (m_creature.weak || c.creature.HawkEye))
            {
                pt = pt.BitMask(StateMachine.PASSIVE_WEAK, true);
            }

            var opt = m_stateMachine.GetLong(StateMachineParam.forcePassive) >> 48 & 0xFFFF;
            if (opt == 0 || pt.BitMask(StateMachine.PASSIVE_CATCH) || !opt.BitMask(StateMachine.PASSIVE_CATCH) && pt.BitMask(StateMachine.PASSIVE_WEAK))
            {
                var tid = breakTough && m_creature.HasState(ts.toToughStateID) ? ts.toToughStateID : ts.toStateID;
                toState = tid;

                var p = pt << 48 | (long)cc.id << 32 | (uint)tid;
                m_stateMachine.SetParam(StateMachineParam.forcePassive, p);

                if (pt.BitMask(StateMachine.PASSIVE_CATCH))
                {
                    m_creature.RemoveBuff(BuffInfo.EffectTypes.Freez);
                }

                if (c.type == AttackColliderTypes.Attack)
                {
                    var mask = m_stateMachine.GetStateMask(toState);
                    cc.stateMachine.SetParam(StateMachineParam.targetGroupMask, mask);
                    cc.stateMachine.SetParam(StateMachineParam.targetHitGroupMask, m_stateMachine.GetLong(StateMachineParam.groupMask));
                    cc.stateMachine.SetParam(StateMachineParam.targetConfigID, m_creature.configID);
                    if (isCatch && !mask.BitMasks(ss.info.ignoreCatchPosGroups) && m_creature.HasState(toState))
                    {
                        if (ss.info.catchState == 1)
                        {
                            m_creature.position_ = cc.position_;
                        }
                        else
                        {
                            cc.position_ = m_creature.position_;
                        }
                    }
                }
            }
            else
            {
                passive = false;
            }
        }

        if (c.type == AttackColliderTypes.Attack)
        {
            cc.stateMachine.SetParam(StateMachineParam.hit, true);
        }

        m_stateMachine.SetParam(StateMachineParam.hited, cc.id);

        cc.DispatchAttackEvent(m_creature, a);
        if (!m_creature.isDead)
        {
            cc.rage += a.selfRageReward * (1 + cc.attackRageMul);                      // ignore rage reward if target is dead
        }
        m_creature.DispatchEvent(CreatureEvents.ATTACKED, Event_.Pop(cc, a));
        if (a.fromBullet)
        {
            m_creature.DispatchEvent(CreatureEvents.SHOOTED, Event_.Pop(m_creature, a));
        }
        if (!m_creature.isDead) // ignore rage reward if target is dead
        {
            m_creature.rage += a.targetRageReward * (1 + m_creature.attackedRageMul);
            m_creature.TakeDamage(cc, cc.CalculateDamage(a, m_creature, ss.damageMul));
        }
        else if (!alive)
        {
            UpdateDeadCombo();
        }

        if (a.freezTime > 0)
        {
            m_stateMachine.Pending(a.freezTime, passive, alive && m_creature.isDead);
            if (!a.fromEffect)
            {
                c.stateMachine.Pending(a.freezTime);
            }
        }

        if (passive)
        {
            if (a.preventTurn == 0)
            {
                if (a.fromBullet)
                {
                    m_creature.FaceTo(cc);
                }
                else
                {
                    var direction = CalculateHitDirection(c, a, m_creature.x);
                    if (direction != 0)
                    {
                        m_creature.direction = direction < 0 ? CreatureDirection.BACK : CreatureDirection.FORWARD;
                    }
                }
            }
            if (a.acttackSlide != 0)
            {
                m_creature.Knockback(m_creature.isForward ? -a.acttackSlide * 0.1 : a.acttackSlide * 0.1);
            }
        }

        var s = a.soundEffect.SelectSound(m_creature.roleProto, m_creature.gender);

        if (!s.isEmpty)
        {
            AudioManager.PlayAudio(s.sound, a.soundEffect.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, a.soundEffect.overrideType);
        }

        if (c.type == AttackColliderTypes.Attack && !a.ignoreHitEffect)
        {
            behaviour.effects.PlayEffect(c.hitEff);
        }

        if (!m_creature.isDead)  // do not trigger buffs if target is dead
        {
            var level = 1;
            if (cc is PetCreature)
            {
                level = ((PetCreature)cc).petInfo.AdditiveLevel;
            }

            var b = a.selfBuff;
            if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0))
            {
                Buff.Create(b.intValue0, cc, null, b.intValue1, -1, level);
            }

            b = a.targetBuff;
            if (b.intValue0 != 0 && (b.doubleValue0 == 0 || Module_Battle.Range() <= b.doubleValue0))
            {
                Buff.Create(b.intValue0, m_creature, cc, b.intValue1, -1, level);
            }
        }

        #region Debug log
        #if DEVELOPMENT_BUILD || UNITY_EDITOR
        Logger.LogInfo("[{3}:{4}-{5}], [{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty, Level.levelTime, creature.frameTime, creature.frameCount);
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(m_creature, "[m_creature.tough = {0},currentState is {1} ss.info.ignoreTough = {2} attackinfo.breaktoughLevel = {3} m_creature.toughLevel = {4} cc.breakToughLevel = {5}", m_creature.tough, m_creature.stateMachine.currentState.name, ss.info.ignoreTough, a.breakToughLevel, m_creature.toughLevel, cc.breakToughLevel);
        Module_AI.LogBattleMsg(m_creature, "[[{0}] hited by attackInfo [{1}], translate to state [{2}]", m_creature.gameObject.name, a.ID, toState == ts.toStateID ? ts.toState : toState == ts.toToughStateID ? ts.toToughState : string.Empty);
        #endif
        #endregion
    }