Пример #1
0
    public void Attack(SkillDataSlot skillData)
    {
        // Assign the real normal attack skill id
        int normalSkillId = 1301999000;

        if (skillData._skillID == 0)
        {
            skillData.SkillLogicId = normalSkillId;
        }

        if (skillData.SkillLogicId == 1301316000)
        {
            Debug.Log("Current skill id is " + skillData.SkillLogicId);
        }
        Skill2D.StartSkill(this.gameObject, skillData);

        UpdatePowerProgress((float)Property.WarshipCurrentPower);
        if (null != animComponent)
        {
            if (skillData.SkillLogicId == normalSkillId)
            {
                animComponent.Play("Attack", PlayMode.StopAll);
            }
            else
            {
                animComponent.Play("Skill", PlayMode.StopAll);
            }
        }

        if (null != emitEffectFont)
        {
            emitEffectFont.EmitEffectFont(gameObject, (GameData.BattleGameData.AttackState)skillData._attckerAttackState, skillData.MSkillData.BasicData.SkillName);
        }
        mPublisher.NotifyAttackStart(this, skillData);
    }
    /// <summary>
    /// Starts the nivose track.
    /// </summary>
    /// <returns>
    /// The nivose track.
    /// </returns>
    /// <param name='trackName'>
    /// Track name.
    /// </param>
    /// <param name='dataSlot'>
    /// Data slot.
    /// </param>
    public CameraTrack StartNivoseTrack(string trackName, SkillDataSlot dataSlot)
    {
        Vector3 tStartPos  = Globals.Instance.MPlayerManager.GetWarship(dataSlot._attackerID).U3DGameObject.transform.position;
        Vector3 tTargetPos = Vector3.zero;

        foreach (SkillDataSlot.AttackTargetData data in dataSlot._attackTargetDataList.Values)
        {
            if (data._isPrimaryTarget)
            {
                WarshipL target = Globals.Instance.MPlayerManager.GetWarship(data._targetID);
                tTargetPos = target.U3DGameObject.transform.position;

                break;
            }
        }

        CameraTrack track = null;

        if (!_mCamTrackList.TryGetValue(trackName, out track))
        {
            Object     obj = Resources.Load(trackName);
            GameObject go  = GameObject.Instantiate(obj) as GameObject;
            go.name = trackName;
            track   = go.GetComponent <CameraTrack>() as CameraTrack;
            _mCamTrackList.Add(trackName, track);
        }

        track.RestartNivoseTrack(true, tStartPos, tTargetPos);

        return(track);
    }
Пример #3
0
 public NiVose(SkillDataSlot dataSlot, WarshipL skillUser) :
     base(dataSlot)
 {
     _mFireDuration = 0.0f;
     _mRTTCam       = null;
     _mSkillUser    = skillUser;
 }
Пример #4
0
    public Skill CreateSkill(SkillDataSlot skillData, WarshipL skillUser)
    {
        Skill skill = null;

        switch (skillData.MSkillData.BasicData.SkillType)
        {
        case ESkillType.SINGLE_NIVOSE:
        case ESkillType.GROUP_NIVOSE:
        case ESkillType.GROUP_REPAIR_NIVOSE:
        {
            skill = new NiVose(skillData, skillUser);
            break;
        }

        default:
        {
            skill = new Skill(skillData);
            break;
        }
        }
        skill.Initialize();

        _skillList.Add(skill);
        return(skill);
    }
Пример #5
0
    public void Begin(GameObject target, SkillDataSlot skillData)
    {
        targetObj = target;
        skillUser = target.GetComponent <FightCellSlot>() as FightCellSlot;

        skillDataSlot = skillData;
        skillState    = SkillState.PREPARE;
    }
Пример #6
0
    public void OnBeAttacked(SkillDataSlot skillData)
    {
        mPublisher.NotifyBeAttacked(this, skillData);

        numCurrBeAttackedPerStep++;

        // Check this warship is death
        long shipId = ShipData.roleCardId;

        SkillDataSlot.AttackTargetData beAttackData = skillData._attackTargetDataList[shipId];

        int damage = beAttackData._beAttackedDamage;

        GameData.BattleGameData.AttackedState attackedState = (GameData.BattleGameData.AttackedState)beAttackData._beAttackedState;
        if (attackedState != GameData.BattleGameData.AttackedState.DODGE)
        {
            Property.WarshipSimulateLife -= damage;

            // tzz modified for damage and cure HP
            if (Property.WarshipSimulateLife > Property.WarshipMaxLife)
            {
                Property.WarshipSimulateLife = Property.WarshipMaxLife;
            }
            // Property.WarshipSimulateLife = Mathf.Clamp(Property.WarshipSimulateLife,0,Property.WarshipMaxLife);

            if (numCurrBeAttackedPerStep == numBeAttackedPerStep)
            {
                // Reset
                numBeAttackedPerStep     = 0;
                numCurrBeAttackedPerStep = 0;

                if (Property.WarshipSimulateLife <= 0.0f)
                {
                    OnDeath();
                }
                else
                {
                    if (null != animComponent)
                    {
                        animComponent.Play("Hit", PlayMode.StopAll);
                        // animComponent.CrossFade("Hit");
                    }
                }
            }
            else
            {
                if (null != animComponent)
                {
                    animComponent.Play("Hit", PlayMode.StopAll);
                }
            }
        }
        else
        {
            if (null != animComponent)
            {
                animComponent.Play("Dodge", PlayMode.StopAll);
            }
        }

        UpdateLifeProgress((float)Property.WarshipSimulateLife);
        UpdatePowerProgress((float)Property.WarshipCurrentPower);

        //tzz added for REDUCE_DAMAGE_SKILL_ATTACKED
        //
        if (!skillData.IsReduceDamangeSkill())
        {
            if (skillData.IsCureSkill())
            {
                emitEffectFont.EmitEffectFont(gameObject, (GameData.BattleGameData.AttackedState)skillData._attckerAttackState, Mathf.Abs(damage));
            }
            else
            {
                emitEffectFont.EmitEffectFont(gameObject, attackedState, damage);
            }
        }

        // tzz added for shaking camera
        List <SkillEffectData.SkillFireParticleData> t_list = skillData._skillEffectData._skillFireParticleList;

        if (t_list.Count > 0 && t_list[t_list.Count - 1]._shakeCamera && skillData.IsNivoseType())
        {
            // iTween.ShakePosition(Globals.Instance.MSceneManager.mMainCamera.gameObject,new Vector3(20,20,0),1);

#if UNITY_IPHONE || UNITY_ANDROID
            if (GameDefines.Setting_ShakeEnable)
            {
                Handheld.Vibrate();
            }
#endif
        }
    }
Пример #7
0
    public void Attack(SkillDataSlot skillData)
    {
        // Assign the real normal attack skill id
        if (skillData._skillID == 0)
        {
            EWarshipTypeID type = (EWarshipTypeID)Property.TypeID;
            switch (type)
            {
            case EWarshipTypeID.AIRCRAFT_CARRIER:
            {
                skillData._skillID = NormaAttackDefine.NORMAL_AIRCRAFT_CARRIER;
                break;
            }

            case EWarshipTypeID.UNDER_WATER_CRAFT:
            {
                skillData._skillID = NormaAttackDefine.NORMAL_UNDER_WATER_CRAFT;
                break;
            }

            default:
            {
                skillData._skillID = NormaAttackDefine.NORMAL_CANNON_CRAFT;
                break;
            }
            }
        }

        // Fill in skill data from DataTable
        skillData.MSkillData.BasicData.SkillLogicID = skillData._skillID;
        skillData.MSkillData.FillDataFromConfig();

        // Create skill, and execute the skill logic
        Skill skill = Globals.Instance.MSkillManager.CreateSkill(skillData, this);

        skill.StartSkill();

        // add attack effect font
        GameData.BattleGameData.AttackState attackState = (GameData.BattleGameData.AttackState)skillData._attckerAttackState;
        BattleBloodControl bloodControl = Globals.Instance.MGUIManager.GetGUIWindow <GUIBattle>()._bloodControl;

        if (attackState == GameData.BattleGameData.AttackState.NORMAL_ATTACK_CRIT)
        {
            bloodControl.EmitEffectFont(_thisGameObject.transform, _thisGameObject.transform.position, new Vector3(0f, 40f, 0f), BattleEffectFont.EffectType.CRIT, 0, "");
        }
        else if (attackState == GameData.BattleGameData.AttackState.SKILL_ATTACK)
        {
            // Only skill attack allow display effect font
            if (!skillData.MSkillData.BasicData.SkillIsNormalAttack)
            {
                bloodControl.EmitEffectFont(_thisGameObject.transform,
                                            _thisGameObject.transform.position, new Vector3(0f, 30f, 0f), BattleEffectFont.EffectType.SKILL, 0, skillData.MSkillData.BasicData.SkillName);
            }
        }
        else if (attackState == GameData.BattleGameData.AttackState.SKILL_ATTACK_CRIT)
        {
            bloodControl.EmitEffectFont(_thisGameObject.transform, _thisGameObject.transform.position, new Vector3(0f, 40f, 0f), BattleEffectFont.EffectType.CRIT_SKILL, 0, skillData.MSkillData.BasicData.SkillName);
        }
        else if (attackState == GameData.BattleGameData.AttackState.TREAT_SKILL_ATTACKED ||
                 attackState == GameData.BattleGameData.AttackState.REDUCE_DAMAGE_SKILL_ATTACKED)
        {
            // tzz added for display name of TREAT_SKILL_ATTACKED and REDUCE_DAMAGE_SKILL_ATTACKED
            //
            bloodControl.EmitEffectFont(_thisGameObject.transform,
                                        _thisGameObject.transform.position, new Vector3(0f, 30f, 0f), BattleEffectFont.EffectType.SKILL, 0, skillData.MSkillData.BasicData.SkillName);
        }
    }
Пример #8
0
    public virtual bool OneBattleStep(int step, GameData.BattleGameData.BattleStep stepData)
    {
        UnityEngine.Profiling.Profiler.BeginSample("BattleStatus.OneBattleStep");

        // Has 3 parts

        /**Part1:
         * 1).Trim the basic data of all warships in this step
         * 2).Calculate the count of a warship is attacked
         * */

        /**Part2:
         * 1).Simulate the all warships running logic
         * 2).Display its
         * */

        /**Part3: Implement in OnOneBattleStepEnd()
         * 1).Trim all warships InitialLife for the next step simulate
         * */
        // Debug.Log("The current stepID is : " + stepData.StepID.ToString());

        foreach (GameData.BattleGameData.BattleShip battleShip in stepData.BattleShips)
        {
            // // Search the Warship
            // WarshipL warship = Globals.Instance.MPlayerManager.GetWarship(battleShip.ShipID);
            //
            // // Assign the base value
            // warship.Property.WarshipCurrentLife = battleShip.CurrentLife;
            // warship.Property.WarshipCurrentPower = (short)battleShip.CurrentPower;

            // Attack is the separate logic
            GameData.BattleGameData.AttackState attackState = battleShip.AttackState;
            if (attackState == GameData.BattleGameData.AttackState.IDLE)
            {
                continue;
            }

            // Construct a skill or a attackEvent? Include multiple be attacked target
            foreach (GameData.BattleGameData.AttackedTarget attackedTarget in battleShip.AttackedTargets)
            {
                // Stat. the num of be attacked
                WarshipL targetWarship = Globals.Instance.MPlayerManager.GetWarship(attackedTarget.ShipID);
                if (null == targetWarship)
                {
                    Debug.Log("[BattleStatus]: Why the target ship " + attackedTarget.ShipID + " is null?");
                    continue;
                }

                targetWarship._numBeAttacked += 1;
            }
        }

        // Part2
        foreach (GameData.BattleGameData.BattleShip battleShip in stepData.BattleShips)
        {
            // Search the Warship
            WarshipL warship = Globals.Instance.MPlayerManager.GetWarship(battleShip.ShipID);
            if (null == warship)
            {
                Debug.Log("[BattleStatus]: Why the ship " + battleShip.ShipID + " is null?");
                continue;
            }

            // Assign the base value
            warship.Property.WarshipCurrentLife  = battleShip.CurrentLife;
            warship.Property.WarshipCurrentPower = (short)battleShip.CurrentPower;

            // tzz added for modify some bug
            //
            warship.GirlData.PropertyData.Life  = battleShip.CurrentLife;
            warship.GirlData.PropertyData.Power = battleShip.CurrentPower;

            Vector3 currentPosition = warship.U3DGameObject.transform.position;

            Vector3 targetPosition = HelpUtil.GetWarFiledGridPosition(battleShip.CurrentPosition);
            targetPosition += SceneOffset;

            // Perform the step logci
            GameData.BattleGameData.MoveState moveState = battleShip.MoveState;
            switch (moveState)
            {
            case GameData.BattleGameData.MoveState.MOVE:
            {
                // move speed
                warship.MoveTo(targetPosition);

                // tzz added
                // for teach first move in Teach first enter scene
                // check TeachFirstEnterGame.cs for detail
                //if(m_teachStartMovingEvent != null){
                //	m_teachStartMovingEvent(TeachBattleEvent.e_startMoving);
                //	m_teachStartMovingEvent = null;
                //
                //	battleStepDuration = 0.0f;
                //	_mDelayTime = DELAY_TIME;
                //}
                break;
            }

            case GameData.BattleGameData.MoveState.STOP:
            {
                warship.ForceMoveTo(targetPosition);
                break;
            }

            case GameData.BattleGameData.MoveState.SINK:
            {
                //warship.ForceSink();
                break;
            }
            }

            // Attack is the separate logic
            GameData.BattleGameData.AttackState attackState = battleShip.AttackState;
            if (attackState == GameData.BattleGameData.AttackState.IDLE)
            {
                continue;
            }

            // tzz added for setting buffer of fire
            if (warship.WarshipHeader != null && battleShip.BattleBuffersList != null)
            {
                warship.WarshipHeader.SetBufferStepInterval(battleShip.BattleBuffersList, step);
            }

            // Only perform the skill effect, construct the skill data now
            SkillDataSlot skillData = new SkillDataSlot(battleShip.SkillLogicID, warship._warshipID, (int)attackState);

            // Construct a skill or a attackEvent? Include multiple be attacked target
            int targetIndex = 0;
            foreach (GameData.BattleGameData.AttackedTarget attackedTarget in battleShip.AttackedTargets)
            {
                WarshipL targetWarship = Globals.Instance.MPlayerManager.GetWarship(attackedTarget.ShipID);
                if (null == targetWarship)
                {
                    Debug.Log("[BattleStatus]: Why the target ship " + attackedTarget.ShipID + " is null?");
                    continue;
                }

                int targetMoveState;
                GetWarshipMoveStateInStep(attackedTarget.ShipID, stepData, out targetMoveState);

                SkillDataSlot.AttackTargetData attackTargetData = new SkillDataSlot.AttackTargetData();

                attackTargetData._targetID         = attackedTarget.ShipID;
                attackTargetData._moveState        = targetMoveState;
                attackTargetData._beAttackedState  = (int)attackedTarget.AttackedState;
                attackTargetData._beAttackedDamage = attackedTarget.Damage;

                if (targetIndex == 0)
                {
                    skillData._primaryTargetID        = attackTargetData._targetID;
                    attackTargetData._isPrimaryTarget = true;
                }
                else
                {
                    attackTargetData._isPrimaryTarget = false;
                }

                skillData._attackTargetDataList.Add(attackedTarget.ShipID, attackTargetData);

                // tzz added for general command show
                if (warship.WarshipHeader != null && warship.WarshipHeader.Avatar != null &&
                    !skillData.MSkillData.BasicData.SkillIsNormalAttack &&             // is NOT normal skill
                    targetIndex == 0)                   // is first target
                {
                    BattleGeneralCmd.ShowGeneralCmd(warship.WarshipHeader.Avatar,
                                                    Globals.Instance.MDataTableManager.GetWordText(skillData.MSkillData.BasicData.SkillWord));
                }

                targetIndex++;
            }

            warship.Attack(skillData);
        }

        UnityEngine.Profiling.Profiler.EndSample();
        return(true);
    }
Пример #9
0
    public static void StartSkill(GameObject target, SkillDataSlot skillData)
    {
        Skill2D skill = target.AddComponent <Skill2D>() as Skill2D;

        skill.Begin(target, skillData);
    }
Пример #10
0
 public void SetProperty(SkillDataSlot skillData)
 {
     _mSkillDataSlot = skillData;
 }
Пример #11
0
 public Skill(SkillDataSlot slotData)
 {
     _mSkillID       = slotData._skillID;
     _mSkillDataSlot = slotData;
 }