コード例 #1
0
ファイル: LightweightLabel.cs プロジェクト: dqtoy/Assets
 public void Initalize(AgentRemote remote, Camera cam)
 {
     canvasCamera = cam;
     navRemote    = remote;
     active       = true;
     //gameObject.SetActive(true);
 }
コード例 #2
0
    private AgentRemote CreatePoolingItem(int id, ListUpgrade type)
    {
        AgentRemote remote = Create(type);

        remote?.FirstSetup(id);
        return(remote);
    }
コード例 #3
0
 private bool AddAgent(int id, AgentRemote remote)
 {
     if (!AllAgents.ContainsKey(id))
     {
         AllAgents.Add(id, remote);
         return(true);
     }
     return(false);
 }
コード例 #4
0
 public void Move(List <Vector3Int> path,
                  List <float> separateTime,
                  Vector3Int curCellPosition,
                  AgentRemote ownerRemote,
                  AgentRemote otherRemote)
 {
     InitMessage(path, separateTime, curCellPosition, ownerRemote, otherRemote);
     Emit("S_MOVE");;
 }
コード例 #5
0
    private void Attack_Action()
    {
        AgentRemote owner = NavAgentController.CurrentAgent.Remote;
        AgentRemote enemy = NavAgentController.GetEnemyAt(NavAgentController.CursorController.SelectedPosition);

        if (!FriendSys.IsMyFriend(enemy.UserInfo.ID_User))
        {
            SIO_AttackListener.S_ATTACK(owner, enemy);
        }
    }
コード例 #6
0
ファイル: LightweightLabel.cs プロジェクト: dqtoy/Assets
    public void Dispose()
    {
        SetHP(1, 1);
        NameInGame   = "";
        Quality      = 0;
        active       = false;
        navRemote    = null;
        canvasCamera = null;

        gameObject.SetActive(false);
    }
コード例 #7
0
 private void LoadAgents()
 {
     Object[] objs = AssetUtil.Load(@"Prefabs\Agents");
     for (int i = 0; i < objs.Length; i++)
     {
         GameObject  go       = objs[i] as GameObject;
         AgentRemote remote   = go.GetComponent <AgentRemote>();
         int         hashCode = remote.Type.GetHashCode();
         AgentPrefabs[hashCode] = remote;
     }
 }
コード例 #8
0
 public void Release(ListUpgrade type, AgentRemote agent)
 {
     if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool))
     {
         pool.Release(agent);
     }
     else
     {
         CreatePool(type).Release(agent);
     }
 }
コード例 #9
0
    private void OnSelected(AgentRemote remote)
    {
        ResizeAnimation.Close();
        MyAgentManager.ActiveNav(remote.AgentID);

        Vector3Int position = remote.CurrentPosition;

        CameraGroup.CameraMoveToAgent(position);
        VisiableCancelButton();

        selectedId = remote.AgentID;
    }
コード例 #10
0
    public void R_MOVE(SocketIOEvent obj)
    {
        //Debugger.Log(obj.ToString().Substring(0,150));
        JSONObject r_move = obj.data["R_MOVE"];
        int        id     = -1;

        r_move.GetField(ref id, "ID");
        if (!MyAgentManager.IsOwnerAgent(id))
        {
            AgentRemote agent = AgentManager.GetAgentRemote(id);
            agent?.FixedMove.StartMove(r_move);
        }
    }
コード例 #11
0
    private Vector3Int FindNextValidPosition(int unitId)
    {
        bool isOwnerAgent = AgentManager.IsOwnerAgent(unitId);

        if (!isOwnerAgent)
        {
            agentRemote = AgentManager.GetAgentRemote(unitId);
            if (agentRemote != null)
            {
                breathFS.GetNearestCell(agentRemote.CurrentPosition, out Vector3Int res);
                return(res);
            }
        }
        return(Generic.Contants.Constants.InvalidPosition);
    }
コード例 #12
0
    public void Add(AgentRemote remote)
    {
        SelectableAgentElement el = selectablePooling.GetItem();

        el.PlaceholderComp.Text = remote.AgentID.ToString();

        el.SelectableComp.OnClickEvents += delegate
        {
            OnSelected(remote);
        };

        el.gameObject.SetActive(true);
        el.RectTransform.SetAsLastSibling();

        Catcher.Add(el);
    }
コード例 #13
0
    public void Create(UnitRow unitData, UserInfoRow user)
    {
        AgentRemote agentRemote = AgentPooling.GetItem(unitData.ID_Unit);

        if (agentRemote == null || user == null)
        {
            return;
        }
        else
        {
            agentRemote.Dispose();
            this.AddAgent(unitData.ID, agentRemote);

            LightweightLabel label = labelPooling.GetItem();
            agentRemote.transform.position = MapIns.CellToWorld(unitData.Position_Cell.Parse3Int().ToClientPosition());

            agentRemote.OnDead += delegate
            {
                AgentPooling.Release(agentRemote.Type, agentRemote);
                labelPooling.Release(label);

                MyAgentRemoteManager.Remove(agentRemote.AgentID);
                this.RemoveAgent(agentRemote.AgentID);
            };

            label.Initalize(agentRemote, MainCamera);
            bool isOwner = unitData.ID_User == PlayerInfo.Info.ID_User;

            agentRemote.Initalize(UnitTable, label, unitData, user, isOwner);

            if (isOwner)
            {
                if (agentRemote.NavAgent == null)
                {
                    agentRemote.gameObject.AddComponent <NavAgent>();
                }
                MyAgentRemoteManager.Add(agentRemote);
                agentRemote.name = "Owner " + unitData.ID;
            }
            else
            {
                agentRemote.name = "other " + unitData.ID;
            }
            agentRemote.gameObject.SetActive(true);
        }
    }
コード例 #14
0
    private void InitBaseDefend()
    {
        // Debugger.Log(baseDefends.Length + " " + baseInfo.Count);
        ReadOnlyCollection <BaseInfoRow> baseInfoRows = SyncData.BaseInfos.ReadOnlyRows;

        for (int i = 0; i < baseDefends.Length && i < baseInfo.Count; i++)
        {
            Vector3 basePos = Map.CellToWorld(baseInfoRows[i].Position.Parse3Int().ToClientPosition());
            for (int j = 0; j < baseDefends[i].Count; j++)
            {
                BaseDefendRow row   = baseDefends[i].ReadOnlyRows[j];
                AgentRemote   agent = Manager.GetItem(row.ID_Unit);
                if (agent != null)
                {
                    agent.transform.position = basePos;
                    agent.gameObject.SetActive(true);
                }
            }
        }
    }
コード例 #15
0
ファイル: AttackInfoGenerator.cs プロジェクト: dqtoy/Assets
    public JSONObject CreateAttackInfo(AgentRemote ownerRemote, AgentRemote otherRemote)
    {
        InfoDict.Clear();
        UnitRow ownerUnit = ownerRemote.UnitInfo;
        UnitRow otherUnit = otherRemote.UnitInfo;

        InfoDict["Server_ID"] = ownerRemote.UserInfo.Server_ID;

        InfoDict["ID_Attack"]      = ownerUnit.ID.ToString();
        InfoDict["ID_Unit_Attack"] = ((int)ownerUnit.ID_Unit).ToString();
        InfoDict["ID_User_Attack"] = ownerUnit.ID_User.ToString();

        InfoDict["ID_Defend"]      = otherUnit.ID.ToString();
        InfoDict["ID_Unit_Defend"] = ((int)otherUnit.ID_Unit).ToString();
        InfoDict["ID_User_Defend"] = otherUnit.ID_User.ToString();

        InfoDict["Position_Cell_Attacker"] = ownerRemote.CurrentPosition.ToSerPosition().ToPositionString();

        JSONObject data = new JSONObject(infoDict);

        Debugger.Log(data);
        return(data);
    }
コード例 #16
0
    public void R_DEPLOY(SocketIOEvent obj)
    {
        //Debugger.Log(obj);
        string  json = obj.data["R_DEPLOY"].ToString();
        UnitRow unit = JsonUtility.FromJson <UnitRow>(json);

        AgentRemote agent    = MyAgent.GetNavRemote(unit.ID);
        int         posCount = positions.Count;

        if (agent != null && posCount > 0)
        {
            agent.NavAgent.AsyncStartMove(agent.CurrentPosition, positions[posCount - 1], null);
            positions.RemoveAt(posCount - 1);
            if (positions.Count > 0)
            {
                Debugger.Log("start coroutine");
                StartCoroutine(DeployCoroutine());
            }
        }
        else
        {
            Debugger.Log("Agent null " + unit.ID);
        }
    }
コード例 #17
0
    private void InitMessage(
        List <Vector3Int> clientPath,
        List <float> separateTime,
        Vector3Int curPosition,
        AgentRemote ownerRemote,
        AgentRemote enemyRemote)
    {
        curPosition = curPosition.ToSerPosition();

        List <Vector3Int> serverPath = new List <Vector3Int>(clientPath);

        for (int i = 0; i < serverPath.Count; i++)
        {
            serverPath[i] = serverPath[i].ToSerPosition();
        }

        serverPath = serverPath.Invert();
        int ownerUnitType = (int)ownerRemote.Type;
        int ownerAgentId  = ownerRemote.AgentID;

        string attack_unit_id = "NULL";

        const string format =
            "{{" +
            "\"Server_ID\":" + "{0}," +
            "\"ID\":" + "{1}," +
            "\"ID_Unit\":" + "{2}," +
            "\"ID_User\":" + "{3}," +
            "\"Position_Cell\":" + "\"{4}\"," +
            "\"Next_Cell\":" + "\"{5}\"," +
            "\"End_Cell\":" + "\"{6}\"," +
            "\"TimeMoveNextCell\":" + "{7}," +
            "\"TimeFinishMove\":" + "{8}," +
            "\"ListMove\":" + "{9}," +
            "\"Attack_Unit_ID\":" + "\"{10}\"" +
            "}}";

        UserInfoRow user        = ownerRemote.UserInfo;
        Vector3Int  endPosition = serverPath[serverPath.Count - 1];

        if (enemyRemote != null)
        {
            UserInfoRow otherUser = enemyRemote.UserInfo;

            attack_unit_id = string.Format("{0}_{1}_{2}_{3}",
                                           user.Server_ID,
                                           (int)enemyRemote.Type,
                                           otherUser.ID_User,
                                           enemyRemote.AgentID);
        }

        moveJson = string.Format(format,
                                 user.Server_ID,
                                 ownerAgentId,
                                 ownerUnitType,
                                 user.ID_User,
                                 curPosition.ToPositionString(),
                                 serverPath[0].ToPositionString(),
                                 endPosition.ToPositionString(),
                                 GMath.SecondToMilisecond(GMath.Round(separateTime[0], 3)),
                                 GMath.SecondToMilisecond(GMath.Round(separateTime.Sum(), 3)),
                                 GetJsonFrom1(serverPath, separateTime, serverPath[0]),
                                 attack_unit_id
                                 );

        moveJson = string.Format("{{\"S_MOVE\":{0}}}", moveJson);
    }
コード例 #18
0
ファイル: RenderFilterObject.cs プロジェクト: dqtoy/Assets
 private void Awake()
 {
     agent = GetComponent <AgentRemote>();
 }
コード例 #19
0
    public void S_ATTACK(AgentRemote owner, AgentRemote other)
    {
        JSONObject attackInfo = AttackInfoGenerator.CreateAttackInfo(owner, other);

        Emit("S_ATTACK", attackInfo);
    }