Example #1
0
        private void InteractInField(InteractiveGameObject initiator, InteractiveGameObject target)
        {
            int index       = rooms.IndexOf(initiator);
            var targetIndex = rooms.IndexOf(target);

            var delta     = targetIndex - index;
            var lastIndex = -1;

            for (int i = targetIndex; IsInBounds(i); i -= delta)
            {
                if (IsInBounds(i - delta))
                {
                    rooms[i] = rooms[i - delta];
                }
                else
                {
                    lastIndex = i;
                }
            }

            rooms[lastIndex] = spawner.GetRandomGroundObject();
            initiator.InteractWith(target);
            initiator.UpdateSelf();
            target.UpdateSelf();

            UpdateSelf();
        }
Example #2
0
        public bool CanInteractInField(InteractiveGameObject initiator, InteractiveGameObject target)
        {
            if (!initiator.CanInteractWith(target))
            {
                return(false);
            }

            int index = rooms.IndexOf(initiator);

            if (index == -1)
            {
                return(false);
            }

            var targetIndex = rooms.IndexOf(target);

            if (targetIndex == -1)
            {
                return(false);
            }

            if (Math.Abs(index - targetIndex) == xStep ||
                Math.Abs(index - targetIndex) == yStep)
            {
                return(true);
            }

            return(false);
        }
Example #3
0
        public virtual void Init(object obj, Type valueType)
        {
            if (valueType == null && obj == null)
            {
                return;
            }

            InteractiveValue interactive;

            if (valueType == typeof(GameObject) || valueType == typeof(Transform))
            {
                interactive = new InteractiveGameObject();
            }
            else if (valueType.IsPrimitive || valueType == typeof(string))
            {
                interactive = new InteractivePrimitive();
            }
            else if (valueType.IsEnum)
            {
                if (valueType.GetCustomAttributes(typeof(FlagsAttribute), true) is object[] attributes && attributes.Length > 0)
                {
                    interactive = new InteractiveFlags();
                }
                else
                {
                    interactive = new InteractiveEnum();
                }
            }
Example #4
0
        public bool SelectItem(InteractiveGameObject selected)
        {
            if (selected == Selected)
            {
                return(false);
            }

            var index = rooms.IndexOf(selected);

            if (index == -1)
            {
                return(false);
            }

            if (selectedIndex == -1)
            {
                Selected      = selected;
                selectedIndex = index;
                Selected.UpdateSelf();
                UpdateSelf();
                return(true);
            }

            if (CanInteractInField(Selected, selected))
            {
                InteractInField(Selected, selected);
                Selected      = null;
                selectedIndex = -1;
                return(true);
            }

            Selected      = null;
            selectedIndex = -1;
            return(false);
        }
Example #5
0
 public PlayerControl(PlayerObject player)
 {
     gameObject = player;
     InitializeComponent();
     this.nameLabel.Text = player.Name;
     powerLabel.Text     = PowerLabels.GetText(player);
 }
Example #6
0
        public IEnumerable <InteractiveGameObject> GetNearbyObjects
            (InteractiveGameObject target)
        {
            int index = rooms.IndexOf(target);

            if (index == -1)
            {
                yield break;
            }

            foreach (var e in GetNearbyObjects(index))
            {
                yield return(e);
            }
        }
Example #7
0
        public CardControl(Card card)
        {
            gameObject = card;
            InitializeComponent();
            this.nameLabel.Text = card.Name;
            this.rarityColorBorder.BackColor = RarityLabels.GetColor(card.Rarity);
            typeLabel.Text = TypeLabels.GetText(card.Type);

            rarityLabel.UseCustomForeColor = true;
            rarityLabel.ForeColor          = RarityLabels.GetColor(card.Rarity);
            rarityLabel.Text = RarityLabels.GetText(card.Rarity);

            descriptionLabel.Text = card.Description;
            powerLabel.Text       = PowerLabels.GetText(card);
        }
 private void RayCastForObject()
 {
     RaycastHit hit;
     Ray ray = camera.ScreenPointToRay (new Vector3 (camera.pixelWidth / 2, camera.pixelHeight / 2, 0));
     if (Physics.Raycast (ray, out hit)) {
         objectHit = hit.transform;
         objectInteractive = hit.transform.gameObject.GetComponent<InteractiveGameObject> ();
         if (objectInteractive) {
             objectLabel = objectInteractive.label;
         } else {
             objectLabel = null;
         }
     } else {
         objectInteractive = null;
         objectLabel = null;
     }
 }
Example #9
0
        public virtual void Init(object obj, Type valueType)
        {
            if (valueType == null && obj == null)
            {
                return;
            }

            //ExplorerCore.Log("Initializing InteractiveValue of type " + valueType.FullName);

            InteractiveValue interactive;

            if (valueType == typeof(GameObject) || valueType == typeof(Transform))
            {
                interactive = new InteractiveGameObject();
            }
            else if (valueType == typeof(Texture2D))
            {
                interactive = new InteractiveTexture2D();
            }
            else if (valueType == typeof(Texture))
            {
                interactive = new InteractiveTexture();
            }
            else if (valueType == typeof(Sprite))
            {
                interactive = new InteractiveSprite();
            }
            else if (valueType.IsPrimitive || valueType == typeof(string))
            {
                interactive = new InteractivePrimitive();
            }
            else if (valueType.IsEnum)
            {
                if (valueType.GetCustomAttributes(typeof(FlagsAttribute), true) is object[] attributes && attributes.Length > 0)
                {
                    interactive = new InteractiveFlags();
                }
                else
                {
                    interactive = new InteractiveEnum();
                }
            }
Example #10
0
 public void SetCurrentInteractiveGameObjectInTheScene(InteractiveGameObject obj)
 {
     CurrentInteractiveGameObject = obj;
 }
Example #11
0
 /// <summary>
 ///     The center of the square obstacle is used by the occlusion frustums calculator.
 /// </summary>
 public TransformStruct GetObstacleCenterTransform()
 {
     return(InteractiveGameObject.GetLogicColliderCenterTransform());
 }
Example #12
0
    // Start is called before the first frame update
    void Awake()
    {
        Instance = this;
        go_start = new GameObject();
        go_end   = new GameObject();

        line = go_start.AddComponent <LineRenderer>();

        line.startColor = Color.green;
        line.endColor   = Color.blue;

        line.startWidth = 0;
        line.endWidth   = 0;

        line.enabled = false;

        Debug.Log("GazeGestureManager Awake!");
        // Set up a GestureRecognizer to detect Select gestures.
        recognizer = new GestureRecognizer();
        recognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.NavigationX | GestureSettings.NavigationY);
        recognizer.Tapped += (args) =>
        {
            if (objectHolded != null)
            {
                objectHolded.setInactive();
                objectHolded = null;
            }
            else
            {
                if (FocusedObject != null)
                { // an object was selected
                    originObject   = FocusedObject;
                    SelectedObject = originObject;
                    while (true)
                    {
                        if (SelectedObject.transform.parent != playground.Instance.world.transform)
                        {
                            SelectedObject = SelectedObject.transform.parent.gameObject;
                        }
                        else
                        {
                            break;
                        }
                    }
                    objectHolded = SelectedObject.GetComponent <InteractiveGameObject>();
                    if (objectHolded != null)
                    {
                        objectHolded.OnAirTapped(hitInfo.point);
                    }
                }
            }
        };
        recognizer.NavigationStarted += (args) =>
        {
            this.handPosition_start = this.handPosition_current;
            //Debug.Log("NavigationStarted: " + this.handPosition_start);
            if (playground.Instance.isCodeEditorOn)
            {
                m_reactor = playground.Instance.m_codeEditor.CurFocusedPanel;
            }
            else if (FocusedObject == null)
            {
                m_reactor = null;
                return;
            }
            else
            {
                originObject   = FocusedObject;
                SelectedObject = FocusedObject;
                while (true)
                {
                    if (SelectedObject.transform.parent != playground.Instance.world.transform)
                    {
                        SelectedObject = SelectedObject.transform.parent.gameObject;
                    }
                    else
                    {
                        m_reactor = SelectedObject.GetComponent <NavigationReactor>();
                        break;
                    }
                }
                line.enabled = true;
            }
            m_reactor.NavigationStart(handPosition_start, originObject);
        };
        recognizer.NavigationUpdated += (args) =>
        {
            if (m_reactor == null)
            {
                return;
            }
            InteractionManager.InteractionSourceUpdatedLegacy += GetPosition;
            float[] rotation_velocity = { 0.5f, 1.0f, 0.5f };// 0.2f;

            Vector3 dif = (this.handPosition_current - this.handPosition_start);



            //Debug.Log("NavigationUpdated: " + this.handPosition_current + "-" + this.handPosition_start + "=" + dif);

            if (!playground.Instance.isCodeEditorOn)
            {
                playground.Instance.PopupPanel.m_text.text = "[MODE: Rotating]";
                line.startColor = Color.green;
                line.endColor   = Color.blue;
                line.GetComponent <Renderer>().material.color = new Color(255, 255, 255, 0.2f);

                line.startWidth = 0.0025f;
                line.endWidth   = 0.02f;

                // Temp
                Vector3 shift = Camera.main.transform.position + Camera.main.transform.forward;
                line.SetPosition(0, shift + (new Vector3(0, 0.05f, 0.0f) + this.handPosition_start));
                line.SetPosition(1, shift + (new Vector3(0, 0.05f, 0.0f) + this.handPosition_current));
            }
            m_reactor.NavigationUpdate(dif, originObject);
        };
        recognizer.NavigationCompleted += (args) =>
        {
            if (m_reactor == null)
            {
                return;
            }
            m_reactor.NavigationEnd(handPosition_current, originObject);
            //if (playground.Instance.isCodeEditorOn)
            //{
            //    playground.Instance.m_codeEditor.CurFocusedPanel.NavigationEnd(handPosition_current);
            //}
            m_reactor    = null;
            line.enabled = false;
        };
        recognizer.NavigationCanceled += (args) =>
        {
            m_reactor    = null;
            line.enabled = false;
            //Debug.Log("NavigationCanceled");
        };
        recognizer.StartCapturingGestures();
        playground.Instance.f_Init();
        isInited = true;
    }