private void LeftMouseUnClick()
 {
     if (selectRectangle.CheckIfBigEnough())        //u got to decide, if you are selecting area, or telling the selected object to do sth
     {
         selectRectangle.MakeSelection();
     }
     else
     {
         selectRectangle.draw = false;            // i tak trza to wylaczyc
         /////////////////Here is sending info about click to objects!
         GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
         Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
         if (hitObject && hitPoint != ResourceManager.InvalidPosition)
         {
             player.selectedObjects.MouseClick(hitObject, hitPoint, player);
             if (hitObject.name != "Ground")
             {
                 WorldObject worldObject = hitObject.transform.parent.GetComponent <WorldObject>();                           //////////////This is selecting!
                 if (worldObject)
                 {
                     //player.selectedObjects.AddOne(worldObject);			<== this is not needed!, everything is made in SetSelection!
                     if (!Input.GetButton("ChangeSelection"))                                 //We are ot editing the amount of selected objects, and the user clicked on some object not while selecting other ones, so we have to clear selection
                     {
                         player.selectedObjects.ClearSelection();
                     }
                     worldObject.SetSelection(true, player.hud.GetPlayingArea());
                     TryToSimulateFire(worldObject);
                 }
             }
         }
         else
         {
         }
     }
 }
예제 #2
0
파일: Player.cs 프로젝트: datketh/aurelion
    public void FindBuildingLocation()
    {
        Vector3 newLocation = WorkManager.FindHitPoint(Input.mousePosition);

        newLocation.y = 0;
        tempBuilding.transform.position = newLocation;
    }
예제 #3
0
 private void RightMouseClickPre()
 {
     if (player && !Input.GetKey(KeyCode.LeftAlt) && player.selectedObjects.Count != 0 && player.selectedObjects[0] != null)
     {
         WorldObject selectedWO = player.selectedObjects [0].GetComponent <WorldObject> ();
         GameObject  hitObject;
         Vector3     hitPoint;
         if (player.selectedObjects.Count == 1 && selectedWO != null)
         {
             RaycastHit closestHit = WorkManager.FindNonSelfHitObject(Input.mousePosition, selectedWO);
             if (closestHit.collider == null)
             {
                 return;
             }
             hitObject = closestHit.collider.gameObject;
             hitPoint  = closestHit.point;
         }
         else
         {
             hitObject = WorkManager.FindHitObject(Input.mousePosition);
             hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
         }
         for (int i = 0; i < player.selectedObjects.Count; i++)
         {
             if (player.selectedObjects[i] != null && player.selectedObjects[i].paramManager.PlayerOwned)
             {
                 player.selectedObjects[i].MouseClickRight(hitObject, hitPoint);
             }
         }
     }
 }
예제 #4
0
 private void LeftMouseClick()
 {
     if (player.hud.MouseInBounds())
     {
         if (player.IsFindingBuildingLocation())
         {
             if (player.CanPlaceBuilding())
             {
                 player.StartConstruction();
             }
         }
         else
         {
             GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
             Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
             if (hitObject && hitPoint != ResourceManager.InvalidPosition)
             {
                 if (player.SelectedObject)
                 {
                     player.SelectedObject.MouseClick(hitObject, hitPoint, player);
                 }
                 else if (hitObject.name != "Ground")
                 {
                     WorldObject worldObject = hitObject.transform.parent.GetComponent <WorldObject>();
                     if (worldObject)
                     {
                         //we already know the player has no selected object
                         player.SelectedObject = worldObject;
                         worldObject.SetSelection(true, player.hud.GetPlayingArea());
                     }
                 }
             }
         }
     }
 }
예제 #5
0
    public void FindBuildingLocation()
    {
        Vector3 newLocation = WorkManager.FindHitPoint(Input.mousePosition, LayerMask.GetMask("Terrain"));

        newLocation.y = 0;
        tmpBuilding.transform.position = newLocation;
    }
예제 #6
0
 private void LeftMouseClick()
 {
     //Deselect();
     if (player.hud.MouseInBounds())
     {
         if (player.IsFindingBuildingLocation())
         {
             if (player.CanPlaceBuilding())
             {
                 player.StartConstruction();
             }
         }
         else if (Input.GetKey(KeyCode.LeftShift))
         {
             Deselect();
             marqueeLeft  = Input.mousePosition;
             marqueeRight = Input.mousePosition;
         }
         else
         {
             GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
             Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
             if (hitObject && hitPoint != ResourceManager.InvalidPosition)
             {
                 WorldObject[] temp = player.SelectedObjects.ToArray();
                 foreach (WorldObject obj in temp)
                 {
                     obj.MouseClick(hitObject, hitPoint, player);
                 }
                 Deselect();
                 if (hitObject.name != "Ground")
                 {
                     WorldObject worldObject = hitObject.transform.parent.GetComponent <WorldObject>();
                     if (worldObject)
                     {
                         //we already know the player has no selected object
                         player.SelectedObjects.Add(worldObject);
                         worldObject.SetSelection(true, player.hud.GetPlayingArea());
                     }
                 }
                 else if (temp.Length > 0)
                 {
                     player.SelectedObjects = new List <WorldObject>(temp);
                     foreach (WorldObject obj in temp)
                     {
                         if (obj)
                         {
                             obj.SetSelection(true, player.hud.GetPlayingArea());
                         }
                         else
                         {
                             player.SelectedObjects.Remove(obj);
                         }
                     }
                 }
             }
         }
     }
 }
예제 #7
0
    public void FindBuildingLocation()
    {
        Vector3 newLocation = WorkManager.FindHitPoint(Input.mousePosition);

        newLocation.y = 0;
        newLocation.x = Mathf.Floor(newLocation.x / 2) * 2;
        newLocation.z = Mathf.Floor(newLocation.z / 2) * 2;
        tempBuilding.transform.position = newLocation;
    }
예제 #8
0
    public void FindBuildingLocation()
    {
        Vector3 newLocation = WorkManager.FindHitPoint();

        if (newLocation != ResourceManager.InvalidPosition)
        {
            buildSpace.position = new Vector3(Mathf.Round(newLocation.x),
                                              Mathf.Round(newLocation.y),
                                              Mathf.Round(newLocation.z));
        }
    }
    private void MiddleMouseUnClick()
    {
        GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
        Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);

        if (hitObject && hitPoint != ResourceManager.InvalidPosition)
        {
            if (hitObject.name != "Ground")
            {
                MoveCameraToObject(hitObject);
            }
        }
    }
예제 #10
0
    //     ---------------     Right Mouse!     ----------------
    private void RightMouseClick()
    {
        GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
        Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);

        if (player.hud.MouseInBounds() && player.SelectedObject)
        {
            if (player.IsFindingBuildingLocation())
            {
                player.CancelBuildingPlacement();
            }
            player.SelectedObject.MouseClick(hitObject, hitPoint, player);
        }
    }
예제 #11
0
    private void LeftMouseClickPre()
    {
        GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);

        if (hitObject)
        {
            WorldObject worldObject = hitObject.transform.GetComponentInParent <WorldObject> ();
            if (worldObject)
            {
                player.FigureOutSelectionAfterLeftClickOnThisWorldObject(worldObject);
            }
            if (player.selectedObjects.Count == 1 && player.selectedObjects[0] != null && player.selectedObjects[0].paramManager.PlayerOwned)
            {
                player.selectedObjects[0].MouseClickLeft(WorkManager.FindHitPoint(Input.mousePosition));
            }
        }
    }
예제 #12
0
    private void LeftMouseClick()
    {
        if (player.hud.MouseInBounds())
        {
            if (player.IsFindingBuildingLocation())
            {
                if (player.CanPlaceBuilding())
                {
                    player.StartConstruction(player.hud.GetPlayingArea());
                }
                return;
            }

            GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
            Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
            if (hitObject && hitPoint != ResourceManager.InvalidPosition)
            {
                if (player.SelectedObject &&
                    player.SelectedObject.MouseClick(hitObject, hitPoint, player))
                {
                    return;
                }
                else if (hitObject.name != "Ground")
                {
                    WorldObject worldObject = hitObject.GetComponent <WorldObject>();
                    if (worldObject == null)
                    {
                        worldObject = hitObject.GetComponentInParent <WorldObject>();
                    }
                    if (worldObject)
                    {
                        if (player.SelectedObject)
                        {
                            player.SelectedObject.SetSelection(false);
                        }
                        player.SelectedObject = worldObject;
                        worldObject.SetSelection(true, player.hud.GetPlayingArea());
                    }
                }
            }
        }
    }
    private void MouseHover()
    {
        if (player.hud.MouseInBounds())
        {
            if (player.IsFindingBuildingLocation())
            {
                player.FindBuildingLocation();
            }
            else
            {
                GameObject hoverObject = WorkManager.FindHitObject(Input.mousePosition);
                Vector3    hitPoint    = WorkManager.FindHitPoint(Input.mousePosition);
                selectRectangle.SetEndCoordinates(Input.mousePosition);
                if (hoverObject)
                {
                    WorldObject Wobj = hoverObject.transform.parent.GetComponent <WorldObject>();
                    if (Wobj != null)
                    {
                        Wobj.SetHoverState(hoverObject);
                    }

                    else if (hoverObject.name != "Ground")
                    {
                        Player owner = hoverObject.transform.root.GetComponent <Player>();
                        if (owner)
                        {
                            Unit     unit     = hoverObject.transform.parent.GetComponent <Unit>();
                            Building building = hoverObject.transform.parent.GetComponent <Building>();
                            if (owner.username == player.username && (unit || building))
                            {
                                player.hud.SetCursorState(CursorState.Select);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #14
0
    private void LeftMouseClick()
    {
        if (player.hud.MouseInBounds())
        {
            if (player.IsFindingBuildingLocation())
            {
                if (player.CanPlaceBuilding())
                {
                    player.StartConstruction();
                }
            }
            else
            {
                GameObject hitObject = WorkManager.FindHitObject(Input.mousePosition);
                Vector3    hitPoint  = WorkManager.FindHitPoint(Input.mousePosition);
                if (hitObject && hitPoint != ResourceManager.InvalidPosition)
                {
                    if (player.SelectedObject)
                    {
                        player.SelectedObject.MouseClick(hitObject, hitPoint, player);
                    }
                    else if (hitObject.name == "LowWall")
                    {
                        if (Application.loadedLevel == 0)
                        {
                            AutoFade.LoadLevel(4, 1f, 1f, Color.black);
                        }
                        else if (Application.loadedLevel == 1)
                        {
                            AutoFade.LoadLevel(0, 1f, 1f, Color.black);
                        }
                        else if (Application.loadedLevel == 2)
                        {
                            //Load The Next level..
                        }
                    }
                    else if (hitObject.name == "Back")
                    {
                        AutoFade.LoadLevel(0, 1f, 1f, Color.black);
                    }
                    else if (hitObject.name == "LowWall2")
                    {
                        AutoFade.LoadLevel(3, 1f, 1f, Color.black);
                    }
                    else if (hitObject.name == "LowWall3")
                    {
                        Application.Quit();
                    }
                    else if (hitObject.name != "Ground" && !hitObject.name.Contains("Tree") && !hitObject.name.Contains("Water") && Application.loadedLevel > 3)
                    {
                        Debug.Log("UserInput child : " + hitObject.name);
                        WorldObject worldObject = hitObject.transform.GetComponent <WorldObject>();
                        //Allows models to recognize mouse input
                        if (worldObject == null)
                        {
                            worldObject = hitObject.transform.parent.GetComponent <WorldObject>();
                        }

                        if (worldObject)
                        {
                            //Debug.Log("Name Of PARENT: " + hitObject.transform.parent.name);
                            //we already know the player has no selected object
                            Debug.Log("UserInput LC is WorldObject: " + hitObject.name);
                            player.SelectedObject = worldObject;
                            worldObject.SetSelection(true, player.hud.GetPlayingArea());
                            if (worldObject.objectName == "Barracks")
                            {
                                audio.PlayOneShot(barracks);
                            }
                            if (worldObject.objectName == "Castle")
                            {
                                audio.PlayOneShot(castle);
                            }
                            if (worldObject.objectName == "Gold Mine")
                            {
                                Debug.Log("GOLDMINE HERE");
                                audio.PlayOneShot(goldmine);
                            }
                            if (worldObject.objectName == "Orc")
                            {
                                audio.PlayOneShot(orc);
                            }
                            if (worldObject.objectName == "Blue Goblin")
                            {
                                audio.PlayOneShot(bluegoblin);
                            }
                            if (worldObject.objectName == "SkullWarrior")
                            {
                                audio.PlayOneShot(skullwarrior);
                            }
                            if (worldObject.objectName == "Demon")
                            {
                                audio.PlayOneShot(demon);
                            }
                        }
                    }
                }
            }
        }
    }