Ejemplo n.º 1
0
 public bool IsValidBuildPos(Vector3 a_pos, int a_buildingType)
 {
     foreach (DictionaryEntry building in m_buildings)
     {
         RemoteBuilding remoteBuilding = (RemoteBuilding)building.Value;
         if (null != remoteBuilding && !remoteBuilding.m_isStatic)
         {
             float sqrMagnitude = (remoteBuilding.transform.position - a_pos).sqrMagnitude;
             if ((!remoteBuilding.m_isMine && Buildings.IsDoor(remoteBuilding.m_type) && sqrMagnitude < 25f) || sqrMagnitude < 0.202499986f)
             {
                 return(false);
             }
         }
     }
     if (!Buildings.IsHarmless(a_buildingType))
     {
         SpecialArea[] specialAreas = m_specialAreas;
         foreach (SpecialArea specialArea in specialAreas)
         {
             if (null != specialArea && (specialArea.m_type == eAreaType.noBuilding || specialArea.m_type == eAreaType.noPvp) && (specialArea.transform.position - a_pos).sqrMagnitude < specialArea.m_radius * specialArea.m_radius)
             {
                 return(false);
             }
         }
     }
     return(Buildings.IsDoor(a_buildingType) || !Raycaster.BuildingSphereCast(a_pos));
 }
Ejemplo n.º 2
0
 private void RemoveNullBuildingsFromList()
 {
     foreach (DictionaryEntry building in m_buildings)
     {
         RemoteBuilding y = (RemoteBuilding)building.Value;
         if (null == y)
         {
             m_buildings.Remove(building.Key);
             break;
         }
     }
 }
Ejemplo n.º 3
0
 private void RemoveNullBuildingsFromList()
 {
     foreach (object obj in this.m_buildings)
     {
         DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
         RemoteBuilding  y = (RemoteBuilding)dictionaryEntry.Value;
         if (null == y)
         {
             this.m_buildings.Remove(dictionaryEntry.Key);
             break;
         }
     }
 }
Ejemplo n.º 4
0
 public Vector3 GetNearbyExplosion(Vector3 a_pos)
 {
     foreach (DictionaryEntry building in m_buildings)
     {
         RemoteBuilding remoteBuilding = (RemoteBuilding)building.Value;
         if (null != remoteBuilding && remoteBuilding.IsExploding())
         {
             float sqrMagnitude = (a_pos - remoteBuilding.transform.position).sqrMagnitude;
             if (sqrMagnitude < 36f)
             {
                 return(remoteBuilding.transform.position);
             }
         }
     }
     return(Vector3.zero);
 }
Ejemplo n.º 5
0
 private void UpdateOrSpawnBuilding(int a_type, Vector3 a_pos, float a_rot, float a_health, bool a_isMine)
 {
     if (0f < a_health)
     {
         string         text           = a_type + a_pos.ToString();
         RemoteBuilding remoteBuilding = (!m_buildings.Contains(text)) ? null : ((RemoteBuilding)m_buildings[text]);
         if (null == remoteBuilding)
         {
             RemoveNullBuildingsFromList();
             GameObject gameObject = (GameObject)Object.Instantiate(m_buildingPrefab);
             gameObject.name = "building_" + text;
             remoteBuilding  = gameObject.GetComponent <RemoteBuilding>();
             remoteBuilding.Init(a_pos, a_type, a_isMine, false);
             m_buildings[text] = remoteBuilding;
         }
         remoteBuilding.Refresh(a_rot, a_health);
     }
 }
Ejemplo n.º 6
0
    public RemoteBuilding GetNearestResource(Vector3 a_pos)
    {
        float          num    = 9999999f;
        RemoteBuilding result = null;

        foreach (DictionaryEntry building in m_buildings)
        {
            RemoteBuilding remoteBuilding = (RemoteBuilding)building.Value;
            if (null != remoteBuilding && Buildings.IsResource(remoteBuilding.m_type))
            {
                float sqrMagnitude = (a_pos - remoteBuilding.transform.position).sqrMagnitude;
                if (sqrMagnitude < num)
                {
                    result = remoteBuilding;
                    num    = sqrMagnitude;
                }
            }
        }
        return(result);
    }
Ejemplo n.º 7
0
    private void InitStaticBuildings()
    {
        ServerBuilding[] array = (ServerBuilding[])Object.FindObjectsOfType(typeof(ServerBuilding));
        for (int i = 0; i < array.Length; i++)
        {
            if (0 < array[i].m_type)
            {
                RemoteBuilding remoteBuilding = array[i].gameObject.AddComponent <RemoteBuilding>();
                remoteBuilding.Init(array[i].transform.position, array[i].m_type, false, true);
            }
            Object.Destroy(array[i]);
        }
        RemoteBuilding[] array2 = (RemoteBuilding[])Object.FindObjectsOfType(typeof(RemoteBuilding));
        string           empty  = string.Empty;

        for (int j = 0; j < array2.Length; j++)
        {
            empty = array2[j].m_type + array2[j].transform.position.ToString();
            m_buildings[empty] = array2[j];
        }
    }
	private bool DisplayMessage(eMsg a_msg)
	{
		bool flag = false;
		int a_prio = 100;
		Vector3 pos = m_client.GetPos();
		switch (a_msg)
		{
		case eMsg.eEatFood:
			flag = (m_inventoryGui.IsVisible() && m_inventoryGui.HasFood());
			break;
		case eMsg.eBuildBuilding:
			flag = (m_inventoryGui.IsVisible() && m_inventoryGui.HasBuilding());
			break;
		case eMsg.eBuildBuilding2:
		{
			int num;
			if (!m_inventoryGui.IsVisible())
			{
				ItemDef itemDef = Items.GetItemDef(m_client.GetHandItem());
				num = ((itemDef.buildingIndex > 0) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			flag = ((byte)num != 0);
			break;
		}
		case eMsg.eShovel:
			flag = (m_inventoryGui.IsVisible() && m_inventoryGui.HasItemType(109));
			break;
		case eMsg.eStarving:
			flag = (0f == m_client.GetEnergy());
			a_prio = 110;
			break;
		case eMsg.ePickupItem:
		{
			RemoteItem nearestItem = m_client.GetNearestItem(pos);
			flag = (null != nearestItem && 25f > (nearestItem.transform.position - pos).sqrMagnitude);
			break;
		}
		case eMsg.eGatherResource:
		{
			RemoteBuilding nearestResource = m_client.GetNearestResource(pos);
			flag = (null != nearestResource && 25f > (nearestResource.transform.position - pos).sqrMagnitude);
			break;
		}
		case eMsg.eAttackEnemy:
		{
			RemoteCharacter nearestNpc = m_client.GetNearestNpc(pos);
			flag = (null != nearestNpc && 36f > (nearestNpc.transform.position - pos).sqrMagnitude);
			break;
		}
		case eMsg.eDriveCar:
		{
			RemoteCharacter nearestCharacter2 = m_client.GetNearestCharacter(pos, true);
			flag = (null != nearestCharacter2 && 36f > (nearestCharacter2.transform.position - pos).sqrMagnitude);
			break;
		}
		case eMsg.eChat:
		case eMsg.ePlayerProfile:
		{
			RemoteCharacter nearestCharacter = m_client.GetNearestCharacter(pos);
			flag = (null != nearestCharacter && 49f > (nearestCharacter.transform.position - pos).sqrMagnitude);
			break;
		}
		}
		if (flag)
		{
			m_msgBar.DisplayMessage(LNG.Get("TUTORIAL_MESSAGE_" + (int)a_msg), a_prio);
		}
		return flag;
	}
Ejemplo n.º 9
0
    private bool DisplayMessage(TutorialMessages.eMsg a_msg)
    {
        bool    flag   = false;
        int     a_prio = 100;
        Vector3 pos    = this.m_client.GetPos();

        switch (a_msg)
        {
        case TutorialMessages.eMsg.ePickupItem:
        {
            RemoteItem nearestItem = this.m_client.GetNearestItem(pos);
            flag = (null != nearestItem && 25f > (nearestItem.transform.position - pos).sqrMagnitude);
            break;
        }

        case TutorialMessages.eMsg.eEatFood:
            flag = (this.m_inventoryGui.IsVisible() && this.m_inventoryGui.HasFood());
            break;

        case TutorialMessages.eMsg.eDriveCar:
        {
            RemoteCharacter nearestCharacter = this.m_client.GetNearestCharacter(pos, true);
            flag = (null != nearestCharacter && 36f > (nearestCharacter.transform.position - pos).sqrMagnitude);
            break;
        }

        case TutorialMessages.eMsg.eGatherResource:
        {
            RemoteBuilding nearestResource = this.m_client.GetNearestResource(pos);
            flag = (null != nearestResource && 25f > (nearestResource.transform.position - pos).sqrMagnitude);
            break;
        }

        case TutorialMessages.eMsg.eAttackEnemy:
        {
            RemoteCharacter nearestNpc = this.m_client.GetNearestNpc(pos);
            flag = (null != nearestNpc && 36f > (nearestNpc.transform.position - pos).sqrMagnitude);
            break;
        }

        case TutorialMessages.eMsg.eStarving:
            flag   = (0f == this.m_client.GetEnergy());
            a_prio = 110;
            break;

        case TutorialMessages.eMsg.eChat:
        case TutorialMessages.eMsg.ePlayerProfile:
        {
            RemoteCharacter nearestCharacter2 = this.m_client.GetNearestCharacter(pos, false);
            flag = (null != nearestCharacter2 && 49f > (nearestCharacter2.transform.position - pos).sqrMagnitude);
            break;
        }

        case TutorialMessages.eMsg.eBuildBuilding:
            flag = (this.m_inventoryGui.IsVisible() && this.m_inventoryGui.HasBuilding());
            break;

        case TutorialMessages.eMsg.eShovel:
            flag = (this.m_inventoryGui.IsVisible() && this.m_inventoryGui.HasItemType(109));
            break;

        case TutorialMessages.eMsg.eBuildBuilding2:
            flag = (!this.m_inventoryGui.IsVisible() && Items.GetItemDef(this.m_client.GetHandItem()).buildingIndex > 0);
            break;
        }
        if (flag)
        {
            this.m_msgBar.DisplayMessage(LNG.Get("TUTORIAL_MESSAGE_" + (int)a_msg), a_prio);
        }
        return(flag);
    }
Ejemplo n.º 10
0
    private void GetMouseInput(float a_deltaTime)
    {
        if (Time.timeSinceLevelLoad < 0.5f)
        {
            return;
        }
        bool    flag          = !this.m_inventory.IsVisible() && !this.m_communicator.IsActive(true) && false == this.m_popupGui.IsActive();
        Vector3 mousePosition = Input.mousePosition;
        bool    flag2         = (this.m_lastMousePos - mousePosition).sqrMagnitude > 4f;

        this.m_lastMousePos = mousePosition;
        Ray ray = Camera.main.ScreenPointToRay(mousePosition);

        if (flag2)
        {
            this.m_hideCursorTime = Time.time + 1f;
        }
        bool flag3 = Time.time < this.m_hideCursorTime;

        if (flag3 != Screen.showCursor)
        {
            Screen.showCursor = flag3;
        }
        if (Input.GetMouseButton(1) && flag)
        {
            this.m_buildRot += a_deltaTime * 90f;
            while (this.m_buildRot > 360f)
            {
                this.m_buildRot -= 360f;
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit raycastHit;
            if (Physics.Raycast(ray, out raycastHit, 100f, 665600))
            {
                int layer = raycastHit.transform.gameObject.layer;
                if (layer != 13)
                {
                    if (layer == 17)
                    {
                        if (!this.m_inventory.IsShopActive())
                        {
                            RemoteItem component = raycastHit.transform.GetComponent <RemoteItem>();
                            if (null != component && this.m_inventory.IsVisible())
                            {
                                this.m_itemGui.Show(component, ray.GetPoint(4.5f));
                            }
                        }
                    }
                }
                else if (flag)
                {
                    RemoteCharacter component2 = raycastHit.transform.GetComponent <RemoteCharacter>();
                    if (null != component2 && null != this.m_client)
                    {
                        ulong steamId = this.m_client.GetSteamId(component2.m_id);
                        if (Global.isSteamActive && 0UL < steamId)
                        {
                            SteamFriends.ActivateGameOverlayToUser("steamid", new CSteamID(steamId));
                        }
                    }
                }
            }
        }
        else if (Input.GetMouseButtonDown(0))
        {
            if (flag)
            {
                this.ResetTarget();
            }
            bool       flag4 = false;
            RaycastHit raycastHit2;
            if (Physics.Raycast(ray, out raycastHit2, 100f, 6995488))
            {
                switch (raycastHit2.transform.gameObject.layer)
                {
                case 9:
                case 13:
                    if (flag)
                    {
                        RemoteCharacter component3 = raycastHit2.transform.GetComponent <RemoteCharacter>();
                        if (null != component3)
                        {
                            if (!component3.m_isOwnPlayer)
                            {
                                this.m_currentTarget = component3;
                                flag4 = true;
                            }
                        }
                        else if (flag && Input.GetAxis("Vertical") == 0f && Input.GetAxis("Horizontal") == 0f)
                        {
                            this.CalculatePath(raycastHit2.point, 12 != raycastHit2.transform.gameObject.layer);
                        }
                    }
                    break;

                case 10:
                case 12:
                case 21:
                    if (flag && Input.GetAxis("Vertical") == 0f && Input.GetAxis("Horizontal") == 0f && null != this.m_client && !this.m_client.IsInVehicle())
                    {
                        Vector3 point = raycastHit2.point;
                        this.m_walkIndicator.position = new Vector3(raycastHit2.point.x, 0.1f, raycastHit2.point.z);
                        this.CalculatePath(point, 12 != raycastHit2.transform.gameObject.layer);
                    }
                    break;

                case 11:
                case 15:
                case 19:
                case 22:
                    flag4 = flag;
                    break;

                case 17:
                    if (this.m_inventory.IsShopActive())
                    {
                        RemoteItem component4 = raycastHit2.transform.GetComponent <RemoteItem>();
                        if (null != component4 && component4.m_type != 254 && this.m_inventory.IsVisible())
                        {
                            this.m_buySellPos = this.m_inventory.ToWorldPos(component4.transform.localPosition);
                            bool    flag5   = this.m_buySellPos.x < 6f;
                            float   num     = (!flag5) ? this.m_inventory.GetShopBuyMultiplier() : this.m_inventory.GetShopSellMultiplier();
                            string  text    = (!flag5) ? LNG.Get("BUY") : LNG.Get("SELL");
                            int     num2    = (int)(Items.GetValue(component4.m_type, component4.m_amountOrCond) * num + 0.5f);
                            string  text2   = (!Items.HasCondition(component4.m_type)) ? ("x " + component4.m_amountOrCond) : (component4.m_amountOrCond.ToString() + "%");
                            ItemDef itemDef = Items.GetItemDef(component4.m_type);
                            if (flag5 || this.m_client.GetGoldCount() >= num2)
                            {
                                string a_caption = string.Concat(new object[]
                                {
                                    text,
                                    "\n",
                                    LNG.Get(itemDef.ident),
                                    "\n",
                                    text2,
                                    "\nfor ",
                                    num2,
                                    " ",
                                    LNG.Get("CURRENCY"),
                                    "?"
                                });
                                this.m_buySellPopupSessionId = this.m_popupGui.ShowGui(true, a_caption);
                            }
                            else
                            {
                                string a_caption2 = string.Concat(new object[]
                                {
                                    LNG.Get("ITEMSHOP_TOO_LESS_GOLD"),
                                    "\n",
                                    num2,
                                    " ",
                                    LNG.Get("CURRENCY")
                                });
                                this.m_popupGui.ShowGui(true, a_caption2);
                            }
                        }
                    }
                    else if (Time.time < this.m_doubleClickTime)
                    {
                        this.m_doubleClickTime = 0f;
                        if (null != raycastHit2.transform)
                        {
                            Vector3 localPosition = raycastHit2.transform.localPosition;
                            Vector3 zero          = Vector3.zero;
                            if (this.m_inventory.DragDrop(ref localPosition, ref zero))
                            {
                                this.m_sendDragPos = localPosition;
                                this.m_sendDropPos = Vector3.zero;
                            }
                        }
                    }
                    else
                    {
                        this.m_dragItem     = raycastHit2.transform;
                        this.m_startDragPos = this.m_dragItem.localPosition;
                    }
                    break;
                }
            }
            if (flag4)
            {
                this.CalculateRotTowardsMouse(mousePosition);
                this.m_stopAttackingTime = Time.time + 0.3f;
            }
        }
        else if (Input.GetMouseButtonUp(0) && null != this.m_dragItem)
        {
            Vector3 startDragPos   = this.m_startDragPos;
            Vector3 localPosition2 = this.m_dragItem.localPosition;
            if (this.m_inventory.DragDrop(ref startDragPos, ref localPosition2))
            {
                if (startDragPos != localPosition2)
                {
                    this.m_sendDragPos = startDragPos;
                    this.m_sendDropPos = localPosition2;
                }
                else
                {
                    this.m_dragItem.localPosition = this.m_startDragPos;
                    this.m_doubleClickTime        = Time.time + 0.5f;
                }
            }
            this.m_dragItem = null;
        }
        if (null != this.m_dragItem)
        {
            this.m_dragItem.position = ray.GetPoint(5f);
            Vector3 localPosition3 = this.m_dragItem.localPosition;
            localPosition3.z = 0f;
            this.m_dragItem.localPosition = localPosition3;
        }
        else if (!flag2)
        {
            if (this.m_mouseOverDur != -1f)
            {
                this.m_mouseOverDur += a_deltaTime;
                if (this.m_mouseOverDur > 0.1f)
                {
                    this.m_buildingHealthIndicator.position = Vector3.up * 1000f;
                    this.m_tooltip.position     = Vector3.up * 1000f;
                    this.m_tooltipHudR.position = Vector3.up * 1000f;
                    this.m_tooltipHudR.parent   = null;
                    this.m_tooltipHudL.position = Vector3.up * 1000f;
                    this.m_tooltipHudL.parent   = null;
                    if (this.m_mouseOverRenderers != null && this.m_mouseOverRenderers.Length != 0)
                    {
                        foreach (Renderer renderer in this.m_mouseOverRenderers)
                        {
                            if (null != renderer)
                            {
                                renderer.gameObject.layer = this.m_mouseOverLayer;
                            }
                        }
                        this.m_mouseOverRenderers = null;
                    }
                    if (null != this.m_mouseOverTransform)
                    {
                        this.m_mouseOverTransform.localScale = this.m_initialMouseOverScale;
                        this.m_mouseOverTransform            = null;
                    }
                    RaycastHit raycastHit3;
                    if (Physics.Raycast(ray, out raycastHit3, 100f, 7007776))
                    {
                        if (raycastHit3.transform.gameObject.layer == 5)
                        {
                            string[] array = raycastHit3.transform.gameObject.name.Split(new char[]
                            {
                                '-'
                            });
                            if (array != null && 1 < array.Length)
                            {
                                if ("tooltip" == array[0])
                                {
                                    this.m_tooltipHudRText.text = LNG.Get(array[1]);
                                    this.m_tooltipHudR.position = raycastHit3.transform.position - raycastHit3.transform.right * 0.3f;
                                    this.m_tooltipHudR.rotation = raycastHit3.transform.rotation;
                                    this.m_tooltipHudR.parent   = raycastHit3.transform;
                                }
                                else if ("mission" == array[0])
                                {
                                    int a_index = 0;
                                    try
                                    {
                                        a_index = int.Parse(array[1]);
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.LogWarning("ClientInput.cs: " + ex.ToString());
                                    }
                                    Mission mission = this.m_client.GetMission(a_index);
                                    if (mission != null)
                                    {
                                        this.m_tooltipHudLText.text = string.Concat(new object[]
                                        {
                                            this.GetMissionText(mission),
                                            LNG.Get("TIME_LEFT"),
                                            ": ",
                                            (int)(mission.m_dieTime / 60f),
                                            " min"
                                        });
                                        this.m_tooltipHudL.position = raycastHit3.transform.position + raycastHit3.transform.right * 0.3f;
                                        this.m_tooltipHudL.rotation = raycastHit3.transform.rotation;
                                        this.m_tooltipHudL.parent   = raycastHit3.transform;
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.m_mouseOverTransform    = raycastHit3.transform;
                            this.m_initialMouseOverScale = this.m_mouseOverTransform.localScale;
                            if (raycastHit3.transform.gameObject.layer == 17)
                            {
                                if (this.m_inventory.IsVisible())
                                {
                                    this.m_inventory.ShowInfo(raycastHit3.transform.position);
                                }
                            }
                            else if (raycastHit3.transform.gameObject.layer == 10)
                            {
                                this.m_mouseOverTransform.localScale *= 1.33f;
                            }
                            else if (raycastHit3.transform.gameObject.layer == 19)
                            {
                                RemoteBuilding component5 = raycastHit3.transform.parent.GetComponent <RemoteBuilding>();
                                if (null != this.m_buildingHealthIndicator && null != component5)
                                {
                                    Vector3 b = Vector3.up * 4f;
                                    float   x = 0.25f * (float)(3 - (int)(component5.m_health * 0.033f));
                                    this.m_buildingHealthIndicator.renderer.material.mainTextureOffset = new Vector2(x, 0f);
                                    this.m_buildingHealthIndicator.position = raycastHit3.transform.position + b;
                                }
                            }
                            else if (raycastHit3.transform.gameObject.layer == 15)
                            {
                                bool    flag6 = "building_10" == raycastHit3.transform.gameObject.name || "building_11" == raycastHit3.transform.gameObject.name;
                                Vector3 b2    = Vector3.up * ((!flag6) ? 3f : 6.5f);
                                this.m_tooltipText.text = LNG.Get("TOOLTIP_RESOURCE");
                                this.m_tooltip.position = raycastHit3.transform.position + b2;
                            }
                            else if (raycastHit3.transform.gameObject.layer == 21)
                            {
                                Vector3 b3 = Vector3.up * 2f;
                                this.m_tooltipText.text = LNG.Get("TOOLTIP_ITEMSTORAGE");
                                this.m_tooltip.position = raycastHit3.transform.position + b3;
                            }
                            else if (raycastHit3.transform.gameObject.layer == 9)
                            {
                                RemoteCharacter component6 = raycastHit3.transform.GetComponent <RemoteCharacter>();
                                if (null == component6)
                                {
                                    Vector3 b4 = Vector3.up * 3f;
                                    this.m_tooltipText.text = LNG.Get("TOOLTIP_INTERACT");
                                    this.m_tooltip.position = raycastHit3.transform.position + b4;
                                }
                            }
                            else if (raycastHit3.transform.gameObject.layer == 22)
                            {
                                MissionObjective component7 = raycastHit3.transform.GetComponent <MissionObjective>();
                                if (null != component7)
                                {
                                    Vector3 b5 = Vector3.up * 3f;
                                    this.m_tooltipText.text = LNG.Get("MISSION_TYPE_" + component7.m_type.ToString("d"));
                                    this.m_tooltip.position = raycastHit3.transform.position + b5;
                                }
                            }
                            this.m_mouseOverRenderers = raycastHit3.transform.GetComponentsInChildren <Renderer>();
                            if (this.m_mouseOverRenderers.Length == 0 && null != raycastHit3.transform.parent)
                            {
                                this.m_mouseOverRenderers = raycastHit3.transform.parent.GetComponentsInChildren <Renderer>();
                            }
                            if (this.m_mouseOverRenderers.Length != 0)
                            {
                                this.m_mouseOverLayer = this.m_mouseOverRenderers[0].gameObject.layer;
                                foreach (Renderer renderer2 in this.m_mouseOverRenderers)
                                {
                                    renderer2.gameObject.layer = 20;
                                }
                            }
                        }
                    }
                    this.m_mouseOverDur = -1f;
                }
            }
        }
        else
        {
            this.m_mouseOverDur = 0f;
        }
    }