Beispiel #1
0
        public static bool SendSkill(CCreature m_creature, BtDatabase m_dataBase, bool bDown = false)
        {
            int targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID);

            if (targetUid == m_creature.GetUid())
            {
                return(false);
            }
            CCreature targetCc = CCreatureMgr.Get(targetUid);

            if (targetCc != null)
            {
                Vector2d dir = (targetCc.GetPos() - m_creature.GetPos());
                dir.Normalize();
                //if (dir == Vector2.zero)
                //{
                //    dir = m_creature.GetDir();
                //}
                int selectSkillUid = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX);

                CSkillInfo skillInfo = m_creature.GetSkillByIndex(selectSkillUid);



                CmdFspSendSkill cmd = new CmdFspSendSkill();
                cmd.m_casterUid  = (int)m_creature.GetUid();
                cmd.m_skillIndex = selectSkillUid;

                if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Self)
                {
                }
                else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Dir ||
                         skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.SectorDir)
                {
                    cmd.m_dir = dir;
                }
                else if (skillInfo.m_skillInfo.selectTargetType == (int)eSelectTargetType.Pos)
                {
                    cmd.m_dir    = dir;
                    cmd.m_endPos = targetCc.GetPos();
                }
                cmd.m_bDown = bDown;

                if (m_creature.m_aiType == eAIType.Player)
                {
                    m_creature.SendFspCmd(cmd);
                }
                else
                {
                    m_creature.PushCommand(cmd);
                }

                // 进入公共CD
                m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, GetSkillCastCd(m_creature, m_dataBase));
                // 清空当前发送的技能
                m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, -1);
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// 常规情况的CD,combo时,缩短CD间隔
        /// </summary>
        public static int GetSkillCastCd(CCreature creature, BtDatabase baseData)
        {
            // 连招状态,取最小间隔
            //if (baseData.GetData<bool>(BOOL_COMBO_STATE))
            //    return INT_HARD_CAST_SKILL_INTERVAL;
            //return INT_HARD_CAST_SKILL_INTERVAL / 2;
            int curInterval = INT_NORMAL_CAST_SKILL_INTERVAL;

            switch (creature.m_ai.m_level)
            {
            case eAILevel.NEWBIE:
                curInterval = INT_NEWBIE_CAST_SKILL_INTERVAL;
                break;

            case eAILevel.EASY:
                curInterval = INT_EASY_CAST_SKILL_INTERVAL;
                break;

            case eAILevel.NORMAL:
                curInterval = INT_NORMAL_CAST_SKILL_INTERVAL;
                break;

            case eAILevel.HARD:
                curInterval = INT_HARD_CAST_SKILL_INTERVAL;
                break;
            }
            return(curInterval);
        }
Beispiel #3
0
 public virtual void Init()
 {
     m_dataBase = new BtDatabase();
     //m_dataBase = GetComponent<BtDatabase>();
     //if(m_dataBase == null)
     //{
     //    m_dataBase = gameObject.AddComponent<BtDatabase>();
     //}
     m_dataBase.SetData <bool>(m_reset, false);
 }
Beispiel #4
0
        public override void Activate(BtDatabase database)
        {
            base.Activate(database);

            for (int i = 0; i < m_condiList.Length; i++)
            {
                m_condiList[i].Activate(database);
            }
            ;
        }
        //Saves the name and the macaddress of the connected potentiostat
        protected virtual async Task <BtDatabase> AsyncTask(BluetoothDevice pairedDevice)
        {
            BtDatabase btDatabase = new BtDatabase
            {
                Name    = pairedDevice.Name,
                Address = pairedDevice.Address
            };
            await App.Database2.SaveScanAsync(btDatabase);

            return(btDatabase);
        }
 public Task <int> SaveScanAsync(BtDatabase scan)   //Saves the current scan into the database
 {
     if (scan.ID != 0)
     {
         return(_database.UpdateAsync(scan));
     }
     else
     {
         return(_database.InsertAsync(scan));
     }
 }
Beispiel #7
0
        public static void SendSkill(CCreature m_creature, BtDatabase m_dataBase)
        {
            int             selectSkillUid = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX);
            CmdFspSendSkill cmd            = new CmdFspSendSkill();

            cmd.m_casterUid  = (int)m_creature.GetUid();
            cmd.m_skillIndex = selectSkillUid;
            cmd.m_bDown      = false;
            m_creature.PushCommand(cmd);

            // 进入公共CD
            m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, GetSkillCastCd(m_creature, m_dataBase));
            // 清空当前发送的技能
            m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, 0);
        }
Beispiel #8
0
        private async void OnBtClicked(object sender, EventArgs e)
        {
            try
            {
                BtDatabase btDatabase = await DependencyService.Get <IBtControl>().TestConn();

                Name.Text    = btDatabase.Name;
                ID.Text      = btDatabase.ID.ToString();
                Address.Text = btDatabase.Address;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                await DisplayAlert("Error", "Cannot find devices with error: " + ex, "OK");
            }
        }
        //Test that a connection to the palmsens exists by getting the name and macaddress
        public async Task <BtDatabase> TestConn()   //Test the connection to the APM
        {
            BtDatabase junk = new BtDatabase();

            try
            {
                if (BluetoothAdapter.DefaultAdapter != null && BluetoothAdapter.DefaultAdapter.IsEnabled)
                {
                    foreach (BluetoothDevice pairedDevice in BluetoothAdapter.DefaultAdapter.BondedDevices)
                    {
                        return(await AsyncTask(pairedDevice));
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            return(junk);
        }
Beispiel #10
0
        public static bool RandomSelectSkill(CCreature m_creature, BtDatabase m_dataBase)
        {
            if (m_canUserSkillList == null)
            {
                m_canUserSkillList = new List <CSkillInfo>();
            }

            // 如果有技能没有被使用,就不进行新的随机
            int skillId = m_dataBase.GetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX);

            if (skillId != -1)
            {
                return(true);
            }

            m_creature.GetCanUseSkillList(ref m_canUserSkillList);

            if (m_canUserSkillList.Count == 0)
            {
                return(false);
            }


            int i;

            if (m_creature.m_aiType == eAIType.Client)
            {
                i = GameManager.Inst.GetRand(0, m_canUserSkillList.Count, 513);
            }
            else
            {
                i = GameManager.Inst.GetClientRand(0, m_canUserSkillList.Count);
            }
            int index = m_canUserSkillList[i].GetSkillIndex();

            m_dataBase.SetData <int>((int)eAIParam.INT_SELECT_SKILL_INDEX, index);
            return(true);
        }
Beispiel #11
0
        public override async void OnReceive(Context context, Intent intent)
        {
            String action = intent.Action;

            if (action != BluetoothDevice.ActionFound)
            {
                return;
            }

            BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);

            if (device.BondState != Bond.Bonded)
            {
                //Add new bt device database
                BtDatabase btDatabase = new BtDatabase
                {
                    Name    = device.Name,
                    Address = device.Address
                };

                await App.Database2.SaveScanAsync(btDatabase);
            }
        }
Beispiel #12
0
    /// <summary>
    /// 传入数据给子节点,并激活
    /// </summary>
    public virtual void Activate(BtDatabase database)
    {
        if (m_actived)
        {
            return;
        }
        this.m_dataBase = database;
        // 激活条件
        if (m_preconditon != null)
        {
            m_preconditon.Activate(database);
        }

        // 激活子节点
        if (m_children != null)
        {
            foreach (BtNode child in m_children)
            {
                child.Activate(database);
            }
        }
        m_actived = true;
    }
 public Task <int> DeleteScanAsync(BtDatabase scan)   //Deletes the current scan from the database
 {
     return(_database.DeleteAsync(scan));
 }
Beispiel #14
0
 public override void Activate(BtDatabase database)
 {
     base.Activate(database);
     m_creature = database.GetData <CCreature>((int)eAIParam.INT_ROLE_UID);
 }
Beispiel #15
0
 public override void Activate(BtDatabase database)
 {
     base.Activate(database);
 }
Beispiel #16
0
        public static bool GetAtkTarget(CCreature m_creature, BtDatabase m_dataBase, int lookDis)
        {
            // 仇恨值高的优先作为目标
            int       hTargetUid = m_creature.m_ai.GetHightHatred();
            CCreature hTargetCC  = CCreatureMgr.Get(hTargetUid);

            if (hTargetUid != -1 &&
                hTargetCC != null &&
                !hTargetCC.IsDie())   // 有仇恨对象,并且没死
            {
                m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, hTargetUid);
            }

            // 如果有目标,判断是否距离足够远,远了就清空目标,继续找附近的
            int       targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID);
            CCreature targetCC  = CCreatureMgr.Get(targetUid);

            if (targetCC == null ||
                FPCollide.GetDis2(targetCC.GetPos(), m_creature.GetPos()) > new FixedPoint(20 * 20) ||
                targetCC.IsDie())  // 隐藏时,不作为目标
            {
                targetUid = 0;
            }
            else
            {
                return(true);
            }

            targetUid = m_creature.GetTarget(lookDis);
            // 如果没有目标,检测玩家附近的单位,锁定目标
            //FixedPoint m_minDis2 = new FixedPoint(999999);
            //List<long> list = CCreatureMgr.GetCreatureList();
            //for (int i = 0; i < list.Count; i++)
            //{
            //    CCreature cc = CCreatureMgr.Get(list[i]);
            //    FixedPoint abDis2 = FPCollide.GetDis2(m_creature.GetPos(), cc.GetPos());
            //    if (abDis2 > new FixedPoint(lookDis * lookDis))
            //        continue;

            //    if (cc.IsDie() || cc.GetUid() == m_creature.GetUid())
            //        continue;
            //    //if (m_creature.bCamp(cc))
            //    //    continue;


            //    if (abDis2 < new FixedPoint(lookDis * lookDis))    // 如果目标在视线范围内
            //    {
            //        if (abDis2 < m_minDis2)
            //        {
            //            targetUid = (int)cc.GetUid();
            //            m_minDis2 = abDis2;
            //        }
            //    }
            //}

            if (targetUid != 0)
            {
                m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, targetUid);
                return(true);
            }
            //m_creature.DestoryDownUpSkill();  // 无目标,结束机枪
            return(false);
        }
Beispiel #17
0
        public const int HARD_CHECK_SKILL_DIS   = 6; // 当前陷阱和弹道用的同一个距离判断,如果太远,AI会检测陷阱出BUG

        /// <summary>
        /// 通用初始化
        /// </summary>
        public static void Init(BtDatabase dataBase)
        {
        }