Esempio n. 1
0
    public void UnsetCarryingItem()
    {
        if (carryingItem.GetComponentInChildren <BoxCollider>() != null)
        {
            carryingItem.GetComponentInChildren <BoxCollider>().enabled = true;
        }

        if (carryingItem.GetComponentInChildren <Rigidbody>() != null)
        {
            carryingItem.GetComponentInChildren <Rigidbody>().detectCollisions = true;
        }

        if (carryingItem is BuildingBase)
        {
            carryingItem.readyToUpdate = true;
        }
        else if (carryingItem is Item)
        {
            carryingItem.readyToUpdate = false;
        }

        float newScaleX = carryingItem.transform.localScale.x / AppConstant.Instance.moveBuildingScaleChange;
        float newScaleY = carryingItem.transform.localScale.y / AppConstant.Instance.moveBuildingScaleChange;
        float newScaleZ = carryingItem.transform.localScale.z / AppConstant.Instance.moveBuildingScaleChange;

        carryingItem.transform.localScale = new Vector3(newScaleX, newScaleY, newScaleZ);
        carryingItem.transform.rotation   = transform.rotation;

        carryingItem.transform.parent = null;
        carryingItem      = null;
        playerActionState = EPlayerActionState.IDLE;
    }
Esempio n. 2
0
    public void SetCarryingItem(InteractiveObject item)
    {
        carryingItem = item;
        if (carryingItem.GetComponentInChildren <BoxCollider>() != null)
        {
            carryingItem.GetComponentInChildren <BoxCollider>().enabled = false;
        }
        RemoveNearbyInteractiveGameObject(carryingItem.gameObject);

        //carryingItem.transform.SetPositionAndRotation(carryingItem.transform.position + this.transform.forward * 1.0f, carryingItem.transform.rotation);
        if (carryingItem is BuildingBase)
        {
            playerActionState          = EPlayerActionState.CARRYING_BUILDING;
            carryingItem.readyToUpdate = false;
        }
        else if (carryingItem is Item)
        {
            playerActionState          = EPlayerActionState.CARRYING_RESOURCE;
            carryingItem.readyToUpdate = true;
        }

        if (carryingItem.GetComponentInChildren <Rigidbody>() != null)
        {
            carryingItem.GetComponentInChildren <Rigidbody>().detectCollisions = false;
        }
        float newScaleX = carryingItem.transform.localScale.x * AppConstant.Instance.moveBuildingScaleChange;
        float newScaleY = carryingItem.transform.localScale.y * AppConstant.Instance.moveBuildingScaleChange;
        float newScaleZ = carryingItem.transform.localScale.z * AppConstant.Instance.moveBuildingScaleChange;

        carryingItem.transform.parent        = this.carryingPivot;
        carryingItem.transform.localPosition = Vector3.zero;
        carryingItem.transform.localScale    = new Vector3(newScaleX, newScaleY, newScaleZ);
    }
Esempio n. 3
0
    public void Initialize(InputController iController, int pId, Transform carryingPivot)
    {
        base.Awake();

        inputController    = iController;
        playerId           = pId;
        carryingItem       = null;
        playerActionState  = EPlayerActionState.IDLE;
        this.carryingPivot = carryingPivot;

        PlayerInputConfig inputConfig = new PlayerInputConfig();

        if (!AppConstant.Instance.isMultiPlayer)
        {
            inputConfig.horizontalAxis = InputAxisEnum.SinglePlayerHorizontal.Value;
            inputConfig.verticalAxis   = InputAxisEnum.SinglePlayerVertical.Value;
            inputConfig.actionButton   = InputAxisEnum.SinglePlayerAction.Value;
        }
        else
        {
            if (IsFirstPlayer())
            {
                inputConfig.horizontalAxis = InputAxisEnum.Player1_Horizontal.Value;
                inputConfig.verticalAxis   = InputAxisEnum.Player1_Vertical.Value;
                inputConfig.actionButton   = InputAxisEnum.Player1_Action.Value;
            }
            else
            {
                inputConfig.horizontalAxis = InputAxisEnum.Player2_Horizontal.Value;
                inputConfig.verticalAxis   = InputAxisEnum.Player2_Vertical.Value;
                inputConfig.actionButton   = InputAxisEnum.Player2_Action.Value;
            }
        }

        inputController.inputConfig = inputConfig;

        nearbyInteractiveGameObjects = new HashSet <GameObject>();
    }
Esempio n. 4
0
 public void SetPlayerActionState(EPlayerActionState state)
 {
     playerActionState = state;
 }