Ejemplo n.º 1
0
    //-----------------------------------------------------------------------------

    //------------------------Mouse Button Commands--------------------------------------------
    public void LeftButton_SingleClickDown(MouseEventArgs e)
    {
        switch (m_Mode)
        {
        case Mode.Normal:
            //We've left clicked, what have we left clicked on?
            int currentObjLayer = currentObject.layer;

            if (currentObjLayer == 8)
            {
                //Friendly Unit, is the unit selected?
                if (m_SelectedManager.IsObjectSelected(currentObject))
                {
                    //Is the unit deployable?
                    if (currentObject.GetComponent <Unit>().IsDeployable())
                    {
                        currentObject.GetComponent <Unit>().GiveOrder(Orders.CreateDeployOrder());
                    }
                }
            }
            break;

        case Mode.PlaceBuilding:
            //We've left clicked, if we're valid place the building
            if (m_PositionValid)
            {
                GameObject newObject = (GameObject)Instantiate(m_ItemBeingPlaced.Prefab, m_ObjectBeingPlaced.transform.position, m_ItemBeingPlaced.Prefab.transform.rotation);
                UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(newObject, "Assets/Scripts - In Game/UI/UIManager.cs (376,5)", m_ItemBeingPlaced.ObjectType.ToString());
                newObject.layer = 12;
                newObject.tag   = "Player";

                BoxCollider tempCollider = newObject.GetComponent <BoxCollider>();

                if (tempCollider == null)
                {
                    tempCollider = newObject.AddComponent <BoxCollider>();
                }

                tempCollider.center    = m_ObjectBeingPlaced.GetComponent <BuildingBeingPlaced>().ColliderCenter;
                tempCollider.size      = m_ObjectBeingPlaced.GetComponent <BuildingBeingPlaced>().ColliderSize;
                tempCollider.isTrigger = true;

                m_ItemBeingPlaced.FinishBuild();
                m_CallBackFunction.Invoke();
                m_Placed = true;
                SwitchToModeNormal();
            }
            break;
        }
    }