Ejemplo n.º 1
0
    public void PropertyUpdate(int id, CharaBase obj, PropertyType type)
    {
        id--;
        pObjs[id].ID = id;

        switch (type)
        {
        case PropertyType.Health:
            pObjs[id].HPpercent = obj.GetHPPercent;
            pObjs[id].HP        = obj.GetHP;
            pObjs[id].buffAmt   = obj.GetDeBuff;
            break;

        case PropertyType.Bullet:
            pObjs[id].bulletAmtPercent = obj.GetBulletPercent;
            pObjs[id].BombAmtPercent   = obj.GetBombPercent;
            pObjs[id].DrugAmtPercent   = obj.GetDrugPercent;
            break;

        case PropertyType.Position:
            Vector2Int pos = new Vector2Int(obj.GetPostionInt.x, obj.GetPostionInt.y);

            string msg = string.Format("汇报(<color=#FFAF23>{0}</color>)的坐标在:(X<color=#FFAF23>{1}</color>,Y<color=#FFAF23>{2}</color>)", obj.Name, pos.x, pos.y);
            MessageSystemMag.instance.AddMessage(msg);

            break;
        }

        foreach (var pobj in pObjs)
        {
            pobj.Refresh();
        }
    }
Ejemplo n.º 2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         touchingEnemyCharaBase = collision.gameObject.GetComponent <CharaBase>();
         touchingEnemyName      = collision.gameObject.name;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// キャラ削除.
 /// </summary>
 /// <param name="chara">消したいキャラ</param>
 static public void Remove(CharaBase chara)
 {
     if (instance == null)
     {
         return;
     }
     instance.m_charaList.Remove(chara.charaId);
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 队伍减员控制
    /// </summary>
    /// <param name="id"></param>
    public void ObjectDie(CharaBase obj)
    {
        int dieid = GetObjId(obj);

        m_objList.Remove(dieid);
        Destroy(obj.gameObject);
        this.Log("剩余队伍数:" + m_objList.Count.ToString());
    }
Ejemplo n.º 5
0
 /// <summary>
 /// キャラ追加.
 /// </summary>
 /// <param name="chara">追加したいキャラ</param>
 static public void Add(CharaBase chara)
 {
     if (instance == null)
     {
         return;
     }
     instance.m_charaList.Add(chara.charaId, chara);
 }
Ejemplo n.º 6
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     if (collision.gameObject.name == touchingEnemyName)
     {
         touchingEnemyName      = null;
         touchingEnemyCharaBase = null;
     }
 }
Ejemplo n.º 7
0
    public void ObjPropertyMessage(CharaBase obj, PropertyType type)
    {
        if (!m_objList.ContainsValue(obj))
        {
            return;
        }

        PropertyMag.instance.PropertyUpdate(GetObjId(obj), obj, type);
    }
Ejemplo n.º 8
0
    //用对象查询ID
    public int GetObjId(CharaBase obj)
    {
        int id = 0;

        foreach (var o in m_objList)
        {
            if (o.Value == obj)
            {
                id = o.Key;
            }
        }
        return(id);
    }
Ejemplo n.º 9
0
    protected void SpriteDisplay()
    {
        CharaBase cmd = GameManager.instance.GetCommand();

        if (cmd == null)
        {
            return;
        }
        if (Vector2.Distance(transform.position, cmd.transform.position) > cmd.GetDetectRadius)
        {
            obj_sprite.enabled = false;
        }
        else
        {
            obj_sprite.enabled = true;
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 遭受攻击并执行反击
    /// </summary>
    /// <param name="objId"></param>
    /// <param name="type"></param>
    /// <returns></returns>
    public IEnumerator Obj_defensive(int objId, int type)
    {
        ObjID = objId;
        CharaBase obj = GameManager.instance.GetObj(objId);

        SoundPlayList.Add(StartOrOver[0]);
        bool fxFlag = false;
        int  copyid = 0;

        copyid = objId < 10 ? 0 : objId == 10 ? 1 : 2;
        switch (type)
        {
        case 0:                                                                //成功低噪音
            //回答
            SoundPlayList.Add(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1]); //报名
            //SoundPlayList.Add(Obj_copy_a[copyid]);//回答
            //具体内容
            SoundPlayList.Add(obj_def_defensive[copyid]);
            fxFlag = false;
            break;

        case 1:
            //高噪音
            SoundPlayList.Add(RandAudio(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1], 0.65f));
            //SoundPlayList.Add(RandAudio(Obj_copy_a[copyid], 0.65f));//回答
            //具体内容
            SoundPlayList.Add(RandAudio(obj_def_defensive[copyid], 0.65f));

            fxFlag = true;
            break;

        case 2:
            //失败噪音
            SoundPlayList.Add(StartOrOver[StartOrOver.Length - 1]);
            fxFlag = true;
            break;
        }
        SoundPlayList.Add(StartOrOver[copyid + 2]);
        yield return(StartCoroutine(ObjCallBackPlay(fxFlag)));
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 单位汇报
    /// </summary>
    /// <param name="index"></param>
    /// <param name="obj"></param>
    /// <param name="type"></param>
    /// <returns></returns>
    public IEnumerator Obj_report_order(int index, CharaBase obj, int type)
    {
        //this.Log(type.ToString());
        SoundPlayList.Add(StartOrOver[0]);
        bool fxFlag = false;
        int  copyid = 0;

        copyid = ObjID < 10 ? 0 : ObjID == 10 ? 1 : 2;
        switch (index)
        {
        case 0:
            //成功低噪音
            SoundPlayList.Add(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1]);    //报名
            //SoundPlayList.Add(Obj_copy_a[copyid]);//回答
            //具体内容
            ObjReport(obj, type, copyid, 1);

            fxFlag = false;
            break;

        case 1:
            //高噪音
            SoundPlayList.Add(RandAudio(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1], 0.65f));
            //SoundPlayList.Add(RandAudio(Obj_copy_a[copyid],0.65f));//回答
            //具体内容
            ObjReport(obj, type, copyid, 0.65f);

            fxFlag = true;
            break;

        case 2:
            //失败噪音
            SoundPlayList.Add(StartOrOver[StartOrOver.Length - 1]);
            fxFlag = true;
            break;
        }
        SoundPlayList.Add(StartOrOver[copyid + 2]);
        yield return(StartCoroutine(ObjCallBackPlay(fxFlag)));
    }
Ejemplo n.º 12
0
 public void Die(CharaBase obj)
 {
     EnemyList.Remove(obj);
     Destroy(obj.gameObject);
 }
Ejemplo n.º 13
0
    /// <summary>
    /// 查询行为
    /// </summary>
    protected virtual void Detect()
    {
        //if (tag.Contains("Enemy")) return;
        RaycastHit2D[] cols   = Physics2D.CircleCastAll(transform.position, DetectRadius, Vector2.zero, 0, LayerMask.GetMask("Player"));
        string         AtkTag = "";

        if (isMine)
        {
            AtkTag = "Enemy";
        }
        else
        {
            AtkTag = "Player";
        }
        foreach (var col in cols)
        {
            CharaBase target = col.collider.GetComponent <CharaBase>();
            if (target.gameObject.CompareTag(AtkTag))
            {
                float distance = Vector2.Distance(transform.position, target.transform.position);
                //this.Log("执行查询-范围内目标:" + target + "距离:"+distance);
                if (GetDetectRate(DetectRate, distance, target.GetStance("Detect"), target.GetDefPercent()))
                {
                    if (!EnemyList.Contains(target))
                    {
                        EnemyList.Add(target);
                    }
                    //this.Log("发现目标:{0},目前敌人列表:{1}" , target.Name,EnemyList.Count);
                    //汇报
                    if (isMine)
                    {
                        if (!AudioSystem.instance.GetIsPlaying && objID != 0)
                        {
                            if (ReportTime <= 0)
                            {
                                //发现目标汇报语音
                                StartCoroutine(AudioSystem.instance.Obj_Enemy_Detected(GetCmdDistance(), objID, this));
                                ReportTime = 30f;
                            }
                        }
                        else
                        {
                            string str = string.Format(Name + ":在坐标(X<color=#FFAF23>{0}</color>,Y<color=#FFAF23>{1}</color>),发现目标:<color=#FFAF23>{2}</color>", target.GetPostionInt.x, target.GetPostionInt.y, target.Name);
                            MessageSystemMag.instance.AddMessage(str);
                        }
                    }
                }
            }
        }

        ////防御姿态主动时攻击
        //if (m_defStatus == objDefStatus.initiative && EnemyList.Count > 0)
        //{
        //    //this.Log("目标对象:" + EnemyList[0]);
        //    if (EnemyList[0] == null)
        //    {
        //        //清理空对象
        //        EnemyList.RemoveAt(0);
        //        //停止状态
        //        m_status = objStatus.empty;
        //        return;
        //    }
        //    else
        //    {
        //        AttackPoint(EnemyList[0].transform.position, objStatus.Attack);
        //        if (isMine)
        //        {
        //            //汇报
        //            string str = string.Format("{0}:与敌方目标<color=#FFAF23>{1}</color>发生交战!", Name, EnemyList[0].Name);
        //            MessageSystemMag.instance.AddMessage(str);
        //        }

        //    }
        //}

        if (EnemyList.Count > 0)
        {
            //遍历目标距离
            for (int i = 0; i < EnemyList.Count; i++)
            {
                if (EnemyList[i] != null)
                {
                    Vector2 target   = EnemyList[i].transform.position;
                    float   distance = Vector2.Distance(transform.position, target);
                    if (distance > DetectRadius)
                    {
                        //失去目标
                        EnemyList.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
    }
Ejemplo n.º 14
0
 [SerializeField] float maxDelayTime;//次の攻撃までの待ち時間
 void Start()
 {
     player   = GameObject.FindGameObjectWithTag("Player");
     playerCB = player.GetComponent <CharaBase>();
 }
Ejemplo n.º 15
0
    /// <summary>
    /// 发现敌方单位汇报
    /// </summary>
    /// <returns></returns>
    public IEnumerator Obj_Enemy_Detected(int type, int objId, CharaBase obj)
    {
        int targetType = (int)obj.type;

        SoundPlayList.Add(StartOrOver[0]);
        bool fxFlag = false;
        int  copyid = 0;

        this.ObjID = objId;
        copyid     = objId < 10 ? 0 : objId == 10 ? 1 : 2;
        Vector2Int targetPos = new Vector2Int(obj.GetPostionInt.x, obj.GetPostionInt.y);
        int        x, y;

        switch (type)
        {
        case 0:                                                                //成功低噪音
            //回答
            SoundPlayList.Add(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1]); //报名
            //SoundPlayList.Add(Obj_copy_a[copyid]);//回答
            //具体内容
            SoundPlayList.Add(Obj_Enemy_detected[targetType][Random.Range(copyid * 2, copyid * 2 + 2)]);
            //X坐标
            x = targetPos.x;
            if (x <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][x], 1));
            }
            else
            {
                int i = x / 10 + 10;
                int j = x % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : x % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], 1));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], 1));
            }
            //Y
            y = targetPos.y;
            if (y <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][y], 1));
            }
            else
            {
                int i = y / 10 + 10;
                int j = y % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : y % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], 1));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], 1));
            }
            fxFlag = false;
            break;

        case 1:
            //高噪音
            SoundPlayList.Add(RandAudio(Obj_callsign_AB[Random.Range(0, 2)][ObjID - 1], 0.65f));
            //SoundPlayList.Add(RandAudio(Obj_copy_a[copyid], 0.65f));//回答
            //具体内容
            SoundPlayList.Add(RandAudio(Obj_Enemy_detected[targetType][Random.Range(copyid * 2, copyid * 2 + 2)], 0.65f));
            //X坐标
            x = targetPos.x;
            if (x <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][x], 0.65f));
            }
            else
            {
                int i = x / 10 + 10;
                int j = x % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : x % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], 0.65f));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], 0.65f));
            }
            //Y
            y = targetPos.y;
            if (y <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][y], 0.65f));
            }
            else
            {
                int i = y / 10 + 10;
                int j = y % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : y % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], 0.65f));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], 0.65f));
            }

            fxFlag = true;
            break;

        case 2:
            //失败噪音
            SoundPlayList.Add(StartOrOver[StartOrOver.Length - 1]);
            fxFlag = true;
            break;
        }
        SoundPlayList.Add(StartOrOver[copyid + 2]);
        yield return(StartCoroutine(ObjCallBackPlay(fxFlag)));
    }
Ejemplo n.º 16
0
    /// <summary>
    /// 三种汇报模式
    /// </summary>
    /// <param name="obj">对象</param>
    /// <param name="type">种类</param>
    /// <param name="copyid">单位类型</param>
    /// <param name="rand">成功率</param>
    void ObjReport(CharaBase obj, int type, int copyid, float rand)
    {
        switch (type)
        {
        case 0:    //检员
            if (obj.GetHPPercent >= 1 && obj.GetDeBuff == 0)
            {
                SoundPlayList.Add(RandAudio(obj_casualty[(copyid + 1) * 3 + (1 * copyid)], rand));
            }
            else if (obj.GetDeBuff > 0 || obj.GetHPPercent < 1)
            {
                SoundPlayList.Add(RandAudio(obj_casualty[Random.Range(copyid * 4, copyid * 4 + 1)], rand));
                SoundPlayList.Add(RandAudio(Obj_p_numbers[copyid][obj.GetHP], rand));
                SoundPlayList.Add(RandAudio(obj_casualty[2 + (4 * copyid)], rand));
                SoundPlayList.Add(RandAudio(Obj_p_numbers[copyid][obj.GetDeBuff], rand));
            }
            break;

        case 1:    //位置
            SoundPlayList.Add(RandAudio(obj_Position_order[Random.Range(copyid * 3, copyid * 3 + 3)], rand));
            Vector2Int pos = new Vector2Int(obj.GetPostionInt.x, obj.GetPostionInt.y);
            //X坐标
            int x = pos.x;
            if (x <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][x], rand));
            }
            else
            {
                int i = x / 10 + 10;
                int j = x % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : x % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], rand));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], rand));
            }
            //Y
            int y = pos.y;
            if (y <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][y], rand));
            }
            else
            {
                int i = y / 10 + 10;
                int j = y % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : y % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], rand));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], rand));
            }
            break;

        case 2:    //补给
            float Qparcent = 0;
            if (copyid != 1)
            {
                Qparcent = obj.GetBulletPercent;
            }
            else
            {
                Qparcent = obj.GetBombPercent;
            }
            int audioID = 0;
            if (Qparcent >= 0.5f)
            {
                audioID = 0;
            }
            else if (Qparcent >= 0.25f)
            {
                audioID = 1;
            }
            else if (Qparcent > 0)
            {
                audioID = 2;
            }
            else
            {
                audioID = 3;
            }
            SoundPlayList.Add(RandAudio(obj_ammo[copyid], rand));
            SoundPlayList.Add(RandAudio(Obj_Quantitys[copyid][audioID], rand));
            SoundPlayList.Add(RandAudio(obj_medic[copyid], rand));
            float Drug = obj.GetDrugPercent;
            if (Drug >= 0.5)
            {
                audioID = 0;
            }
            else if (Drug >= 0.25f)
            {
                audioID = 1;
            }
            else if (Drug > 0)
            {
                audioID = 2;
            }
            else
            {
                audioID = 3;
            }
            SoundPlayList.Add(RandAudio(Obj_Quantitys[copyid][audioID], rand));
            break;
        }
    }
Ejemplo n.º 17
0
    public IEnumerator Obj_Enemy_Killed(int type, int AtkobjId, int objId)
    {
        SoundPlayList.Add(StartOrOver[0]);
        bool fxFlag = false;
        int  copyid = AtkobjId < 10 ? 0 : AtkobjId == 10 ? 1 : 2;

        Debug.Log("击杀者ID:" + AtkobjId);
        //坐标
        CharaBase  obj     = GameManager.instance.GetObj(objId);
        Vector2Int pos     = new Vector2Int(obj.GetPostionInt.x, obj.GetPostionInt.y);
        int        killsId = objId == 0 ? 2 : objId < 10 ? 3 : objId == 10 ? 1 : 4;

        Debug.Log("击杀单位ID:" + killsId.ToString() + "单位ID:" + ObjID);
        switch (type)
        {
        case 0:                                                                   //成功低噪音
            //回答
            SoundPlayList.Add(Obj_callsign_AB[Random.Range(0, 2)][AtkobjId - 1]); //报名
            //位于
            SoundPlayList.Add(obj_enemy_killed[copyid * 5]);


            //X坐标
            int x = pos.x;
            if (x <= 10)
            {
                SoundPlayList.Add(Obj_Coordinates[copyid][x]);
            }
            else
            {
                int i = x / 10 + 10;
                int j = x % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : x % 10 + 10;
                SoundPlayList.Add(Obj_Coordinates[copyid][i]);
                SoundPlayList.Add(Obj_Coordinates[copyid][j]);
            }
            //Y
            int y = pos.y;
            if (y <= 10)
            {
                SoundPlayList.Add(Obj_Coordinates[copyid][y]);
            }
            else
            {
                int i = y / 10 + 10;
                int j = y % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : y % 10 + 10;
                SoundPlayList.Add(Obj_Coordinates[copyid][i]);
                SoundPlayList.Add(Obj_Coordinates[copyid][j]);
            }
            //具体内容
            SoundPlayList.Add(obj_enemy_killed[copyid * 5 + killsId]);
            fxFlag = false;
            break;

        case 1:
            //高噪音
            float rand = 0.65f;
            //X坐标
            x = pos.x;
            if (x <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][x], rand));
            }
            else
            {
                int i = x / 10 + 10;
                int j = x % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : x % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], rand));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], rand));
            }
            //Y
            y = pos.y;
            if (y <= 10)
            {
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][y], rand));
            }
            else
            {
                int i = y / 10 + 10;
                int j = y % 10 < 1 ? Obj_Coordinates[copyid].Length - 1 : y % 10 + 10;
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][i], rand));
                SoundPlayList.Add(RandAudio(Obj_Coordinates[copyid][j], rand));
            }
            //具体内容
            SoundPlayList.Add(RandAudio(obj_enemy_killed[copyid * 5 + killsId], rand));
            fxFlag = true;
            break;

        case 2:
            //失败噪音
            SoundPlayList.Add(StartOrOver[StartOrOver.Length - 1]);
            fxFlag = true;
            break;
        }
        SoundPlayList.Add(StartOrOver[copyid + 2]);
        yield return(StartCoroutine(ObjCallBackPlay(fxFlag)));
    }