public void OnMouseButton(Vector3 mousePosition, StateInformation stateInformation)
    {
        IPlacedObject    selectedObject       = stateInformation.selectedObject;
        MouseButtonState leftMouseButtonState = leftMouseButton.GetState();

        // moving the Object
        if (leftMouseButtonState == MouseButtonState.DOWN)
        {
            selectedObject.SetAllCollidersStatus(false);
        }
        else if (leftMouseButtonState == MouseButtonState.PRESSED)
        {
            selectedObject.RemoveWeaponFromPerson();
            //selectedObject.SetAllCollidersStatus(false);
            objectEditingModule.MoveObject(selectedObject, mousePosition);
        }
        else if (leftMouseButtonState == MouseButtonState.UP)
        {
            selectedObject.SetAllCollidersStatus(true);
        }

        // Giving an Enemy a Weapon
        if (leftMouseButtonState == MouseButtonState.UP && lastLeftMouseButtonState == MouseButtonState.PRESSED)
        {
            IPlacedObject hoveredObject    = stateInformation.hoveredObject;
            bool          objectCanBeGiven = objectInformationModule.CheckIfWeaponCanBeGivenToPerson(selectedObject, hoveredObject);
            if (objectCanBeGiven)
            {
                // give selectedObject to hoveredObject
                objectEditingModule.GiveWeaponToPerson(selectedObject, hoveredObject);
            }
        }
        lastLeftMouseButtonState = leftMouseButtonState;
    }
Esempio n. 2
0
    public void RemoveWeaponFromPerson()
    {
        if (personWhichBelongsTo == null)
        {
            return;
        }

        Weapon weapon = this.prefab.GetComponent <Weapon>();

        if (weapon == null)
        {
            return;
        }

        Person person = personWhichBelongsTo.Prefab.GetComponent <Person>();

        if (person == null)
        {
            return;
        }

        transform.SetParent(LevelCreator.GetInstance().transform);
        weapon.SetSortingLayerOfTextureOfWeapon(SortingLayerConstants.ITEM_LAYER_NAME);
        weapon.SetAnimatorOnFloorFlag(true);
        personWhichBelongsTo.SetAllCollidersStatus(true);
        this.personWhichBelongsTo = null;
        person.Weapon             = null;
    }