Exemple #1
0
    private CreatureStateHud.TUIElement GetElementForTouch(TouchData touchData, CreatureState creatureState, UnityEngine.Vector2 currentPosition)
    {
        for (int index = 0; index < _weaponUIDataArray.Count; ++index)
        {
            WeaponUIData weaponUIData = _weaponUIDataArray[index];
            if ((false == weaponUIData.clickedOn) && (weaponUIData.rect.Contains(touchData.start)))
            {
                CreatureStateHud.THandPose pose = CreatureStateHud.THandPose.Swing;
                var distance = (currentPosition - touchData.start).magnitude;
                var position = currentPosition;
                if (distance < weaponUIData.rect.width * 0.5f)
                {
                    pose     = CreatureStateHud.THandPose.Shoot;
                    position = new UnityEngine.Vector2(UnityEngine.Screen.width * 0.5f, UnityEngine.Screen.height * 0.5f)
                               + (currentPosition - touchData.start);
                }
                creatureState.creatureStateHud.handPoseArray.Add(new CreatureStateHud.HandPoseData()
                {
                    handPose = pose,
                    position = position
                });
                weaponUIData.clickedOn    = true;
                _weaponUIDataArray[index] = weaponUIData;
                return(CreatureStateHud.TUIElement.None);
            }
        }

        //dont start a move/ hand action if click was on
        foreach (CreatureStateHud.UIElementData uiElementData in creatureState.creatureStateHud.uiElementDataArray)
        {
            //uiElementData.r
            var rect = CreatureHud2D.UIPositionToRect(uiElementData.position);
            if (rect.Contains(touchData.start))
            {
                return(CreatureStateHud.TUIElement.None);
            }
        }

        CreatureStateHud.TUIElement uiElement = CreatureStateHud.TUIElement.None;
        if (touchData.start.x < (UnityEngine.Screen.width * 0.25f))
        {
            uiElement = CreatureStateHud.TUIElement.Movement;
        }
        else if ((UnityEngine.Screen.width * 0.75f) < touchData.start.x)
        {
            uiElement = CreatureStateHud.TUIElement.View;
        }
        else
        {
            uiElement = CreatureStateHud.TUIElement.None;
            creatureState.creatureStateHud.handPoseArray.Add(new CreatureStateHud.HandPoseData()
            {
                handPose = CreatureStateHud.THandPose.Empty,
                position = currentPosition
            });
        }
        return(uiElement);
    }
Exemple #2
0
    /// <summary>
    /// UIを更新
    /// </summary>
    /// <param name="data">情報(WeaponUIData型)</param>
    public void Update(WeaponUIData data)
    {
        root.active       = data.enable;
        WeaponNumber.text = "Weapon" + data.weaponNumber;
        Name.text         = data.weaponName;
        Reload.value      = data.reload > 1 ? 1 : (data.reload < 0 ? 0 : data.reload);
        Icon.texture      = data.icon;

        int now = data.now < 0 ? 0 : (data.now > 999 ? 999 : data.now);
        int max = data.max < 0 ? 0 : (data.max > 999 ? 999 : data.max);

        bool X = (data.type == WeaponType.GUN);

        Reload.enabled = n2.enabled = n1.enabled = n0.enabled = m2.enabled = m1.enabled = m0.enabled = X; //剣などの近接武器なら弾数やリロードUIを非表示に...

        n2.texture = GameScene_UI_Manager.ui.getNum[now / 100];
        n1.texture = GameScene_UI_Manager.ui.getNum[now % 100 / 10];
        n0.texture = GameScene_UI_Manager.ui.getNum[now % 10];

        m2.texture = GameScene_UI_Manager.ui.getNum[max / 100];
        m1.texture = GameScene_UI_Manager.ui.getNum[max % 100 / 10];
        m0.texture = GameScene_UI_Manager.ui.getNum[max % 10];
    }