Example #1
0
    public void SetTargetShape(TargetShape shape, TargetEntity entity)
    {
        _targetShape  = shape;
        _targetEntity = entity;

        // Reset actual tile
        _mouseTile = -1;
    }
Example #2
0
 public TargetZone(TargetShape shape, int range = 1, int radius = 0, bool projectile = true)
 {
     Shape      = shape;
     Range      = range;
     Radius     = radius;
     Projectile = projectile;
     Trail      = new List <Loc>();
     Targets    = new List <Loc>();
 }
Example #3
0
        public TargetZone(TargetShape shape, int range = 1, int radius = 0, bool projectile = true, bool directional = true)
        {
            Shape       = shape;
            Range       = range;
            Radius      = radius;
            Projectile  = projectile;
            Directional = directional;
            Trail       = new List <Loc>();
            Targets     = new List <Loc>();

            Pierce = shape == TargetShape.Pierce;
        }
            private void Set()
            {
                var shape = new TargetShape();

                shape.name       = setTargetShape;
                shape.parameters = new float[sourceShape.Length];

                for (int i = 0; i < shape.parameters.Length; i++)
                {
                    shape.parameters[i] =
                        source.GetBlendShapeWeight(source.sharedMesh.GetBlendShapeIndex(sourceShape[i]));
                }

                targetShape.Add(shape);
            }
Example #5
0
    void OnMouseDown()
    {
        Destroy(gameObject);
        GameObject  targetShape       = GameObject.Find("TargetShape");
        TargetShape targetShapeScript = (TargetShape)targetShape.GetComponent(typeof(TargetShape));
        string      shapeName         = transform.name.Replace("(Clone)", "");

        Debug.Log(targetShapeScript.shapeName.text.ToString());
        if (shapeName == targetShapeScript.shapeName.text.ToString())
        {
            Score scoreScript = (Score)score.GetComponent(typeof(Score));
            scoreScript.incrementScore();
        }
        else
        {
            Lives livesScript = lives.GetComponent <Lives>() as Lives;
            if (livesScript != null)
            {
                Debug.Log("Life");
                livesScript.decrementLives();
                Debug.Log(livesScript.count);
            }
        }
    }
Example #6
0
    /// <summary>
    /// Place given object
    /// </summary>
    /// <param name="placementObject">The object to place</param>
    /// <param name="requiredSpace">The bounds of the object to place</param>
    /// <param name="requiredSurfaceSpace">The bounds of the bottom of the shape to place, only used for edge and floor/ceiling placement</param>
    /// <returns></returns>
    public STPlacementResult Place(GameObject placementObject, Vector3 requiredSpace, Vector3 requiredSurfaceSpace = default(Vector3))
    {
        if (!solverIsInit)
        {
            solverIsInit = SpatialUnderstandingDllObjectPlacement.Solver_Init() == 1;
        }

        Result = new SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult();

        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule>       nativeRules       = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule>();
        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> nativeConstraints = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint>();

        foreach (STPlacementRule rule in Rules)
        {
            nativeRules.Add(rule.ToNativeRule());
        }

        foreach (STPlacementConstraint con in Constraints)
        {
            nativeConstraints.Add(con.ToNativeConstraint());
        }

        IntPtr rulePtr       = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(nativeRules.ToArray());
        IntPtr constraintPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(nativeConstraints.ToArray());
        IntPtr definitionPtr = IntPtr.Zero;

        switch (Type)
        {
        case STPlacementType.Floor:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnFloor(requiredSpace));
            break;

        case STPlacementType.Wall:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnWall(requiredSpace, MinHeight, MaxHeight));
            break;

        case STPlacementType.Ceiling:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnCeiling(requiredSpace));
            break;

        case STPlacementType.Shape:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnShape(requiredSpace, TargetShape.ShapeName, TargetShape.GetComponentIndex(TargetShapeComponent)));
            break;

        case STPlacementType.Edge:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnEdge(requiredSpace, requiredSurfaceSpace));
            break;

        case STPlacementType.FloorAndCeiling:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnFloorAndCeiling(requiredSpace, requiredSurfaceSpace));
            break;

        case STPlacementType.RandomInAir:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_RandomInAir(requiredSpace));
            break;

        case STPlacementType.MidAir:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_InMidAir(requiredSpace));
            break;

        case STPlacementType.UnderPlatformEdge:
            definitionPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_UnderPlatformEdge(requiredSpace));
            break;

        default:
            return(null);
        }

        if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(QueryName + "_" + placementObject.name, definitionPtr, Rules.Count, rulePtr, Constraints.Count, constraintPtr, SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()) > 0)
        {
            _hasRun = true;
            Debug.Log("Placing object for query " + QueryName);

            Result = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();

            GameObject resultantObject = GameObject.Instantiate(placementObject, Result.Position, Quaternion.LookRotation(Result.Forward, Result.Up));
            if (resultantObject.GetComponent <STPlacedObject>() == null)
            {
                STPlacedObject placedObject = resultantObject.AddComponent <STPlacedObject>();
                placedObject.PlacedObjectName = QueryName + "_" + placementObject.name;
            }
            // TODO: Add a component to the object to remove it from Spatial Understanding if removed in Unity.
            return(new STPlacementResult(resultantObject, Result));
        }
        else
        {
            Debug.Log("Failed to place object for query " + QueryName);
            _hasRun = true;
            return(null);
        }
    }