void OnMouseDown()
 {
     Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
     if (GameObject.FindObjectOfType <Selector>().IsCreation())
     {
         DGTProxyRemote.GetInstance().RequestSpawnUnit(x, y, GameObject.FindObjectOfType <Selector>().GetUnitCreationType());
         GameObject.FindObjectOfType <Selector>().ResetState();
     }
     else if (GameObject.FindObjectOfType <Selector>().IsListen())
     {
         GameObject.FindObjectOfType <Selector>().GetWillMoveUnit().GetComponent <UnitBehaviour>().SetTarget(x, y);
         GameObject.FindObjectOfType <Selector>().ResetState();
     }
     else if (GameObject.FindObjectOfType <Selector>().IsBuild())
     {
         TileBehaviour currentTile = GameObject.FindObjectOfType <Selector>().GetCurrentTile().GetComponent <TileBehaviour>();
         if (x == currentTile.x + 1 || x == currentTile.x - 1 || y == currentTile.y + 1 || y == currentTile.y - 1)
         {
             DGTProxyRemote.GetInstance().BuildRequest(currentTile.x, currentTile.y, x, y);
         }
         GameObject.FindObjectOfType <Selector>().ResetState();
     }
     else
     {
         if (GetComponentInChildren <UnitBehaviour>() && GetComponentInChildren <UnitBehaviour>().isOwner)
         {
             GetComponentInChildren <UnitBehaviour>().Stop();
             if (GetComponentInChildren <UnitBehaviour>().direction == 0)
             {
                 GameObject.FindObjectOfType <Selector>().SetCurrentTile(gameObject);
                 GameObject.FindObjectOfType <ToolTipManager>().ShowToolTip();
             }
         }
     }
 }
 void Update()
 {
     if (DGTProxyRemote.GetInstance().IsStart() && !isStart)
     {
         isStart = true;
         transform.parent.GetComponent <Animator>().SetTrigger("Start");
     }
     if (transform.parent.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("PreState") && !isReady)
     {
         isReady = true;
         DGTProxyRemote.GetInstance().Ready();
     }
     if (transform.parent.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("PullOut") && !isStarting)
     {
         headerPanel.SetActive(true);
         headerPanel.GetComponent <Animator>().SetTrigger("Start");
         isStarting = true;
     }
     if (headerPanel.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Start") && !isStarted)
     {
         bottomPanel.SetActive(true);
         bottomPanel.GetComponent <Animator>().SetTrigger("Start");
         isStarted = true;
     }
 }
 public void UpdateDirection()
 {
     if (path.Count > 0)
     {
         int targetX = path[0][0];
         int targetY = path[0][1];
         path.RemoveAt(0);
         if (x == targetX && y < targetY)
         {
             DGTProxyRemote.GetInstance().RequestChangeDirection(x, y, 4);
         }
         else if (x == targetX && y > targetY)
         {
             DGTProxyRemote.GetInstance().RequestChangeDirection(x, y, 3);
         }
         else if (y == targetY && x > targetX)
         {
             DGTProxyRemote.GetInstance().RequestChangeDirection(x, y, 1);
         }
         else if (y == targetY && x < targetX)
         {
             DGTProxyRemote.GetInstance().RequestChangeDirection(x, y, 2);
         }
     }
 }
Пример #4
0
    public void OnUpdateUnit(int packed_id, PacketReader pr)
    {
        int x       = pr.ReadUInt8();
        int y       = pr.ReadUInt8();
        int changeX = pr.ReadUInt8();
        int changeY = pr.ReadUInt8();
        int type    = pr.ReadInt8();
        int status  = 0;

        if (type != -1)
        {
            int   direction = pr.ReadUInt8();
            float hp        = pr.ReadFloat();
            bool  isHide    = pr.ReadUInt8() == 1;
            bool  isOwner   = pr.ReadUInt8() == 1;
            status = pr.ReadUInt8();
            DGTProxyRemote.GetInstance().OnUpdateUnit(x, y, changeX, changeY, type, direction, hp, isHide, isOwner, status);
            return;
        }
        else
        {
            status = pr.ReadUInt8();
        }
        DGTProxyRemote.GetInstance().OnUpdateUnit(x, y, changeX, changeY, type, 0, 0, false, false, status);
    }
Пример #5
0
 void Update()
 {
     if (DGTProxyRemote.GetInstance().IsLoggedIn() && !show)
     {
         ShowJoin();
     }
 }
 void CheckAndUpdatePosition(bool condition)
 {
     if (condition)
     {
         DGTProxyRemote.GetInstance().RequestUpdateUnit(x, y);
     }
 }
Пример #7
0
    public void OnUpdateTile(int packed_id, PacketReader pr)
    {
        int x    = pr.ReadUInt8();
        int y    = pr.ReadUInt8();
        int type = pr.ReadUInt8();

        DGTProxyRemote.GetInstance().OnUpdateTile(x, y, type);
    }
Пример #8
0
    public void UpdateHP(int packet_id, PacketReader pr)
    {
        float hp   = pr.ReadFloat();
        float opHp = pr.ReadFloat();
        int   atk  = pr.ReadUInt8();

        DGTProxyRemote.GetInstance().UpdateHP(hp, opHp, atk);
    }
 public static DGTProxyRemote GetInstance()
 {
     if (!instance)
     {
         instance = GameObject.FindObjectOfType <DGTProxyRemote>();
         DontDestroyOnLoad(instance.gameObject);
     }
     return(instance);
 }
Пример #10
0
    public void Connect()
    {
        string name = GetComponentsInChildren <Text>()[1].text;

        if (name == "")
        {
            return;
        }
        PlayerPrefs.SetString("name", name);
        DGTProxyRemote.GetInstance().Login(PlayerPrefs.GetString("name"));
        gameObject.SetActive(false);
    }
 void Awake()
 {
     if (!instance)
     {
         instance = this;
         packet   = new DGTPacket(this);
         SetState(State.DISCONNECTED);
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != instance)
         {
             Destroy(this.gameObject);
         }
     }
 }
    IEnumerator ConnectToServer()
    {
        DGTPacket.Config pc = new DGTPacket.Config("localhost", 1111);
        remote = DGTProxyRemote.GetInstance();
        remote.Connect(pc.host, pc.port);
        remote.ProcessEvents();
        yield return(new WaitForSeconds(0.1f));

        for (int i = 0; i < 10; i++)
        {
            if (remote.IsConnected() || remote.IsConnectionFailed())
            {
                break;
            }
            remote.ProcessEvents();
            yield return(new WaitForSeconds(0.1f));
        }
        if (remote.IsConnected())
        {
            string name = PlayerPrefs.GetString("name");
            Debug.Log(name);
            if (name != "")
            {
                remote.Login(name);
            }
            else
            {
                GameObject.FindObjectOfType <ConnectionManager>().AskName();
            }
        }
        else
        {
            GameObject.FindObjectOfType <ConnectionManager>().ShowConnectionLost();
        }
        yield break;
    }
 public void HideRequest()
 {
     DGTProxyRemote.GetInstance().Hide(x, y);
 }
Пример #14
0
    public void UpdateBoard(int packed_id, PacketReader pr)
    {
        string boardFloorsStr = pr.ReadString();

        DGTProxyRemote.GetInstance().OnUpdateBoard(boardFloorsStr);
    }
Пример #15
0
 public void OnCancelRoom(int packet_id, PacketReader pr)
 {
     DGTProxyRemote.GetInstance().OnCancelRoom();
 }
Пример #16
0
    public void ReceiveCreatedRoomResponse(int packet_id, PacketReader pr)
    {
        int id = pr.ReadUInt32();

        DGTProxyRemote.GetInstance().OnCreatedRoom(id);
    }
Пример #17
0
 private void ReceiveLoggedInResponse(int packet_id, PacketReader pr)
 {
     DGTProxyRemote.GetInstance().OnLoggedInSuccess();
 }
Пример #18
0
 // Use this for initialization
 void Start()
 {
     boardFloor = new GameObject[16, 16];
     boardUnit  = new GameObject[16, 16];
     DGTProxyRemote.GetInstance().RequestBoard();
 }
Пример #19
0
 public DGTPacket(DGTProxyRemote remote) : base()
 {
     this.remote = remote;
     PacketMapper();
 }
Пример #20
0
 private void OnMouseDown()
 {
     DGTProxyRemote.GetInstance().CancelRoom();
 }
Пример #21
0
    public void UpdateTime(int packet_id, PacketReader pr)
    {
        int time = pr.ReadUInt8();

        DGTProxyRemote.GetInstance().UpdateTime(time);
    }
Пример #22
0
 public void Create()
 {
     DGTProxyRemote.GetInstance().CreateRoom(0);
     GameObject.FindObjectOfType <ConnectionManager>().ShowCancel();
 }
Пример #23
0
 public void NotifyStart(int packet_id, PacketReader pr)
 {
     DGTProxyRemote.GetInstance().NotifyStart();
 }
Пример #24
0
 public void UpdateUnit(int x, int y, int changeX, int changeY, int type, int direction, float hp, bool isHide, bool isOwner, int status)
 {
     Debug.Log("x = " + x + " y = " + y + " changeX = " + changeX + " changeY = " + changeY + " direction = " + direction + " hp = " + hp + " isHide = " + isHide + " isOwner = " + isOwner);
     if (!boardUnit[x, y])
     {
         boardFloor[x, y].GetComponent <TileBehaviour>().OnSpawnUnit(type);
         if (type == -1)
         {
             return;
         }
         boardUnit[x, y] = Instantiate(unitPrototype[type], GetPositionOfTile(x, y) + new Vector3(0f, 0f, -10f), Quaternion.identity);
         boardUnit[x, y].transform.SetParent(boardFloor[x, y].transform);
         boardUnit[x, y].GetComponent <UnitBehaviour>().type = type;
         boardUnit[x, y].GetComponent <UnitBehaviour>().SetPosition(x, y);
         boardUnit[x, y].GetComponent <UnitBehaviour>().Own(isOwner);
         boardUnit[x, y].GetComponent <UnitBehaviour>().SetHp(hp);
         DGTProxyRemote.GetInstance().RequestChangeDirection(x, y, 3);
         if (isOwner)
         {
             GameObject.FindObjectOfType <NotificationManager>().NotifySpawnUnit();
         }
     }
     else
     {
         boardUnit[x, y].GetComponent <UnitBehaviour>().SetDirection(direction);
         if (status == 0)
         {
             Debug.Log("Normal");
         }
         else if (status == 1)
         {
             Debug.Log("Attack");
             GetComponent <AudioSource>().clip = attackingSound;
             GetComponent <AudioSource>().Play();
             boardUnit[x, y].GetComponent <DirectionController>().Attack();
         }
         else if (status == 2)
         {
             GetComponent <AudioSource>().clip = deadSound;
             GetComponent <AudioSource>().Play();
             boardUnit[x, y].GetComponent <DirectionController>().Dead();
             StartCoroutine(DeadAnim(x, y));
             if (!isOwner)
             {
                 GameObject.FindObjectOfType <NotificationManager>().NotifyKillEnemy();
             }
         }
         else if (status == 3)
         {
             boardFloor[x, y].GetComponent <TileBehaviour>().Explosion();
         }
     }
     if (x != changeX || y != changeY)
     {
         boardUnit[changeX, changeY] = boardUnit[x, y];
         boardUnit[changeX, changeY].transform.SetParent(boardFloor[changeX, changeY].transform);
         boardUnit[changeX, changeY].transform.position = GetPositionOfTile(changeX, changeY) + boardUnit[x, y].GetComponent <UnitBehaviour>().offsetVector;
         boardUnit[changeX, changeY].GetComponent <UnitBehaviour>().SetPosition(changeX, changeY);
         boardUnit[changeX, changeY].GetComponent <UnitBehaviour>().UpdateDirection();
         boardUnit[x, y] = null;
     }
     else if (x == changeX && y == changeY && type == -1)
     {
         Destroy(boardUnit[x, y]);
         boardUnit[x, y] = null;
         if (status == 3)
         {
             boardFloor[x, y].GetComponent <TileBehaviour>().Explosion();
         }
     }
     else
     {
         boardUnit[x, y].GetComponent <UnitBehaviour>().SetHp(hp);
         boardUnit[x, y].GetComponent <UnitBehaviour>().Hide(isHide);
     }
 }
Пример #25
0
    public void OnResult(int packet_id, PacketReader pr)
    {
        int result = pr.ReadUInt8();

        DGTProxyRemote.GetInstance().OnResult(result);
    }