Esempio n. 1
0
    public void SetEndPipeConfig()
    {
        GameShapeType type     = GameShapeType.CIRCLE;
        Vector3       vector3  = new Vector3(0f, -3f, 0);
        GamePipeEnd   pipeEnd1 = new GamePipeEnd(type, vector3);

        vector3 = new Vector3(2f, -3f, 0);

        type = GameShapeType.SQUARE;
        GamePipeEnd pipeEnd2 = new GamePipeEnd(type, vector3);

        vector3 = new Vector3(-2f, -3f, 0);

        type = GameShapeType.TRIANGLE;
        GamePipeEnd pipeEnd3 = new GamePipeEnd(type, vector3);

        GamePipeEnd[] pipeEndArray = { pipeEnd1, pipeEnd2, pipeEnd3 };
        pipeEnds = pipeEndArray;

        if (onPipeEndAdded != null)
        {
            foreach (GamePipeEnd pipeEnd in pipeEndArray)
            {
                onPipeEndAdded(pipeEnd);
            }
        }
    }
Esempio n. 2
0
 public GameShape(GameShapeType type, GameSpawner spawner, float speed, float spawnSpeed)
 {
     PercentualTraveled = 0;
     Spawner            = spawner;
     this.Type          = type;
     this.Speed         = speed;
     SpawnSpeed         = spawnSpeed;
     this.Position      = spawner.SpawnPosition;
     State = GameShapeState.SPAWNING;
 }
    public GameShape CreateShape(GameShapeType newShapeType, GameSpawner spawner, float speed, float spawnSpeed)
    {
        GameShape shape = new GameShape(newShapeType, spawner, speed, spawnSpeed);

        ShapePipePair newPair = new ShapePipePair
        {
            Shape = shape
        };

        Pairs.Add(newPair);

        return(shape);
    }
    public GamePipeView GetLastTouchedWithType(GameShapeType type)
    {
        GamePipeView lastPipeView = null;
        int          highestIndex = -1;

        foreach (GamePipeView pipeView in pipeViewList)
        {
            if (pipeView.GetTypeAttached() == type && pipeView.LastTouchIndex > highestIndex)
            {
                lastPipeView = pipeView;
                highestIndex = pipeView.LastTouchIndex;
            }
        }
        return(lastPipeView);
    }
    public void OnPipeUpdated(GamePipe pipe)
    {
        ArrayList pairs = GetShapePipePair(pipe);

        if (pairs.Count > 0)
        {
            foreach (ShapePipePair pair in pairs)
            {
                GameShapeType pipeEnd   = pair.AttachedPipe.CurrentEndType;
                GameShapeType shapeType = pair.Shape.Type;
                if (pipeEnd == shapeType)
                {
                    UpdateState(pair.Shape, GameShapeState.CORRECT_MOVING);
                }
            }
        }
    }
    private GameObject GetPipeEndPrefab(GameShapeType type)
    {
        switch (type)
        {
        case GameShapeType.CIRCLE:
            return(bottomCircle);

        case GameShapeType.SQUARE:
            return(bottomSquare);

        case GameShapeType.TRIANGLE:
            return(bottomTriangle);

        default:
            Debug.Log("invalid shape type");
            return(null);
        }
    }
Esempio n. 7
0
    private GameObject GetShapePrefab(GameShapeType type)
    {
        switch (type)
        {
        case GameShapeType.SQUARE:
            return(squarePrefab);

        case GameShapeType.CIRCLE:
            return(circlePrefab);

        case GameShapeType.TRIANGLE:
            return(trianglePrefab);

        default:
            Debug.Log("invalid shape type");
            return(null);
        }
    }
Esempio n. 8
0
    protected void SpawnShape(GameSpawner spawner = null)
    {
        if (spawner == null)
        {
            int spawnerIndex = UnityEngine.Random.Range(0, spawners.Length);
            spawner = spawners[spawnerIndex];
        }

        GameShapeType newShapeType = spawner.GetRandomShapeType();

        GameShape shape = shapeController.CreateShape(newShapeType, spawner, speed, spawnSpeed);

        spawner.CurrentShapes++;

        shape.RegisterOnStateChanged(CallShapeStateChanged);

        if (onShapeCreated != null)
        {
            onShapeCreated(shape);
        }
    }
 public GamePipeEnd(GameShapeType type, Vector3 position)
 {
     this.Type     = type;
     this.Position = position;
 }
Esempio n. 10
0
 public void UpdateGamePipeEnd(GamePipeEnd newEnd, GameShapeType newEndType)
 {
     pipeEnd  = newEnd;
     pipeSize = Vector3.Distance(StartPoint, CurrentEnd);
     OnPipeUpdated(this);
 }