Script to filter all the mouse actions, including moving and clicking the buttons. Right now, we use left click to 'select' units and buildings, and right click to issue 'action' commands
상속: MonoBehaviour
예제 #1
0
        protected Entity SetMouseInput(float2 position)
        {
            var mousePosition = new MouseWorldPosition()
            {
                Position = position, Delta = float2.zero
            };
            var tileUnderMouse = new TileUnderMouse();

            var entity = _entityManager.CreateEntity(mousePosition.GetType(), tileUnderMouse.GetType());

            _entityManager.SetComponentData(entity, mousePosition);
            _entityManager.SetComponentData(entity, tileUnderMouse);

            return(entity);
        }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        setSlot(1,1);
        nextSlotPosition++;

        if (allMonkeys == null)
            allMonkeys = new ArrayList();
        if (boxYposition == null)
            boxYposition = new ArrayList();
        if (yDirection == null)
            yDirection = new ArrayList();

        playerScript = GameObject.Find("Player").GetComponent<CPlayer>();
        mainScript = GameObject.Find("Codigo").GetComponent<MainScript>();
        eventosMenu = GameObject.Find("Codigo").GetComponent<EventosMenu>();

        mouseWorld = GameObject.Find("Codigo").GetComponent<MouseWorldPosition>();

        boxYmax = 600;
        boxYmin = 670;

        xDirection = 0;
        allRects = new ArrayList();
    }
예제 #3
0
        private void OnPointDrag(MarkupPoint point)
        {
            var normal = point.Enter.CornerDir.Turn90(true);

            Line2.Intersect(point.Position.XZ(), (point.Position + point.Enter.CornerDir).XZ(), MouseWorldPosition.XZ(), (MouseWorldPosition + normal).XZ(), out float offsetChange, out _);

            point.Offset = (point.Offset + offsetChange * Mathf.Sin(point.Enter.CornerAndNormalAngle)).RoundToNearest(0.01f);
        }
예제 #4
0
    /*
     * ===========================================================================================================
     * UNITY'S STUFF
     * ===========================================================================================================
     */
    /// <summary>
    /// Executed when the script is loaded
    /// </summary>	
    void Awake()
    {
        Script = this;

        myCam = gameObject.GetComponent<Camera>();

        Transform tCodigo = GameObject.Find("Codigo").transform;
        inputStuffScript = tCodigo.gameObject.GetComponent<MouseWorldPosition>();
        if(inputStuffScript == null) {

            // DEBUG
            Debug.LogError("Cannot find the input script");
        }

        if(micListener == null) {

            // DEBUG
            Debug.LogError("Cannot find the 'microphone' object. Set it in the inspector.");
        }

        mainScript = tCodigo.gameObject.GetComponent<MainScript>();
    }
예제 #5
0
    /// <summary>
    /// Attack a target. Actually, 'attack' could be replaced by 'perform some action on...', because we using
    /// this function also to repair buildings, capture rocket parts, etc.
    /// </summary>
    /// <param name="transTarget"> Transform of the targeted object </param>
    /// <param name="currentMouseState"> A enum with the mouse state when the player issued an order </param>
    /// <summary>
    /// Performs the 'attack' of the monkey
    /// </summary>
    public void PerformAction(Transform transTarget, MouseWorldPosition.eMouseStates currentMouseState)
    {
        this.transTarget = transTarget;

        mouseState = currentMouseState;

        // DEBUG
        Debug.LogWarning(this.transform + " performing " + mouseState);

        // Go into pursuit mode -> walk to the target. When it is in range, perform the action
        EnterNewState(FSMState.STATE_PURSUIT);
    }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        bottomMenu = GetComponent<GUIBottomMenu>();
        if(!bottomMenu) {

            // DEBUG
            Debug.LogError("Bottom menu object not found!");
        }

        player = playerObject.GetComponent<CPlayer>();
        if(!player) {

            // DEBUG
            Debug.LogError("Player object not found!");
        }

        fTaxaConsumoOxigenio = 1.0f;
        fTaxaExtract = 1.0f;
        fTaxaFabrica = 1.0f;

        GetCurrentUnitsInScene();

        mouseInputScript = gameObject.GetComponent<MouseWorldPosition>();
        if(!mouseInputScript) {

            // DEBUG
            Debug.LogError("Cannot find the MouseWorldPosition component. Please check.");
        }

        questManager = gameObject.GetComponent<QuestManager>();
        if(!questManager) {

            // DEBUG
            Debug.LogError("Cannot find the QuestManager component. Please check.");
        }

        //Instantiate(GameObject.("Monkey"), new Vector3(79.07609f,33.39249f,13.41692f), Quaternion.identity);

        // Get all the monkeys in the scene and assign their objects to some variables, so we have shortcuts to them
        GetMonkeysObjects();
    }