Exemplo n.º 1
0
 private void Awake()
 {
     // Initial Ref
     _transform = transform;
     _rotater   = GetComponent <Rotater>();
     _rusher    = GetComponent <Rusher>();
     _timer     = GetComponent <Timer>();
 }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     rotater = gameObject.GetComponent <Rotater>();
     foreach (GameObject objects in GameObject.FindGameObjectsWithTag(tagName + Controllernumber))
     {
         parts.Add(objects);
         objects.SetActive(false);
     }
 }
Exemplo n.º 3
0
 private void Awake()
 {
     // Initial Ref
     _transform  = transform;
     _rotater    = GetComponent <Rotater>();
     _rusher     = GetComponent <Rusher>();
     _earnEffect = _transform.Find("Earn").GetComponent <ParticleSystem>();
     _lostEffect = _transform.Find("Lost").GetComponent <ParticleSystem>();
     _saveEffect = _transform.Find("Save").GetComponent <ParticleSystem>();
 }
Exemplo n.º 4
0
    void Start()
    {
        Input.compass.enabled = true;
        //TODO: record beginning offset values
        //Model and original should have the same starting position
        string[] files = Directory.GetFiles(path);
        rotaters = new Rotater[files.Length];

        for (int i = 0; i < files.Length; i++)
        {
            string name = getNameFromPath(files[i]);
            Debug.Log($"{name} found");
            Transform child = GameObject.Find(name).transform;
            rotaters[i] = new Rotater(files[i], child);
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Rotate the given rotater.
    /// </summary>
    /// <param name="rotater">Rotater.</param>
    /// <param name="clockWize">If set to <c>true</c> clock wize.</param>
    /// <param name="init">If set to <c>true</c> we are rotating to the data
    /// backing, so don't rotate the data backing</param>
    private void DoRotate(Rotater rotater, bool clockWize, bool init)
    {
        int sign;

        if (clockWize)
        {
            sign = 1;
        }
        else
        {
            sign = -1;
        }
        bool rotated = true;

        if (!init)
        {
            rotated = engine[rotater.x, rotater.y].rotate(clockWize);
        }
        if (rotated)
        {
            rotater.transform.rotation *= Quaternion.AngleAxis(90 * sign, Vector3.up);
        }
//		Debug.Log("Rotated " + rotater.x + ", " + rotater.y);
    }
Exemplo n.º 6
0
        /**
         * Constructor
         */
        public GameBoard(Vector2 boardPosition,
                         TileSet tileSet,
                         Difficulty difficulty,
                         int width,
                         int height,
                         int playerIndex)
        {
            //set constructor params
            this.position         = boardPosition;
            this.originalPosition = boardPosition;
            this.difficulty       = difficulty;
            this.height           = height;
            this.width            = width;
            this.numTilesHeight   = difficulty.GetNumberOfTilesInTheGameboardHeight();
            this.numTilesWidth    = difficulty.GetNumberOfTilesInTheGameboardWidth();
            this.startingSpeed    = difficulty.GetStartingSpeed(); //milliseconds
            this.currentSpeed     = startingSpeed;
            this.playerIndex      = playerIndex;
            this.tileSet          = tileSet;

            //init stuff
            this.random               = new Random();
            this.animatableSprites    = new List <SpriteObject>();
            this.timeBeforeSpeedUp    = 60000; //game speeds up every 60 seconds by default
            this.speedUpIncrement     = 50;    //tiles drop 1/20th of a second faster every time the game speeds up
            this.minGameSpeed         = difficulty.GetMaxSpeed();
            this.numTilesToDrop       = difficulty.GetNumberOfTilesToDropPerRound();
            this.paused               = true;
            this.scaleTiles           = false;
            this.bulletTimeActive     = false;
            this.bulletTimeLeft       = 0;
            this.gameOver             = false;
            this.timeDownHeld         = 0;
            this.speedUpIncrement     = 15;
            this.timeBeforeSpeedUp    = 60000;
            this.speedupEnabled       = true;
            this.minGameSpeed         = 150;
            this.timeSinceLastSpeedUp = 0;
            this.isShaking            = false;
            this.timeLeftShaking      = 0;
            this.timeSinceLastShake   = 0;
            this.fadeFromWhiteAlpha   = 1;
            this.maxBulletTime        = 15000; //bullet time is 15 seconds long by default

            this.rotater = new Rotater(this.tileSet.rotater, 0, this.numTilesWidth - 2, 1);
            this.animatableSprites.Add(this.rotater);

            int startingPower;

            if (!SwitchGame.DEBUG_MODE)
            {
                startingPower = 0;
            }
            else
            {
                startingPower = 100;
            }
            this.stats = new GameboardStats(startingPower);
            this.tiles = new TileList(numTilesWidth, numTilesHeight, stats);

            this.gameBoardRect = new Rectangle((int)boardPosition.X,
                                               (int)boardPosition.Y,
                                               (int)(boardPosition.X + width),
                                               (int)(boardPosition.Y + height));

            boardBackgroundSpriteObject = new DetailedSpriteObject(tileSet.boardBackground, new Rectangle((int)(boardPosition.X - 10), 0, width + 20, height + 111));
            nukeSpriteObject            = new DetailedSpriteObject(tileSet.nukeImage, new Rectangle((int)originalPosition.X, (int)originalPosition.Y, width, height));
            blankWhiteSpritObject       = new DetailedSpriteObject(tileSet.blankImage, new Rectangle((int)originalPosition.X, (int)originalPosition.Y, width, height));
        }
Exemplo n.º 7
0
 public void DoRotate(Rotater rotater, bool clockWize)
 {
     DoRotate(rotater, clockWize, false);
 }
Exemplo n.º 8
0
    /// <summary>
    /// Create a GameObject for the TrackBlock at this location
    /// </summary>
    /// <returns>The track piece.</returns>
    /// <param name="x">The x coordinate.</param>
    /// <param name="y">The y coordinate.</param>
    private GameObject generateTrackPiece(int x, int y)
    {
        GameObject         factoryObject;
        AbstractTrackBlock trackBlock = engine[x, y];

        switch (trackBlock.getTrackType())
        {
        case TrackType.Curved:
            factoryObject = curved;
            break;

        case TrackType.Straight:
            factoryObject = straight;
            break;

        case TrackType.DoubleCurved:
            factoryObject = doubleCurved;
            break;

        case TrackType.DoubleStraight:
            factoryObject = doubleStraight;
            break;

        case TrackType.Station:
            throw new NotImplementedException("Creating Station blocks is " +
                                              "not implemented");

        default:
            throw new InvalidOperationException("Unknown track type: " +
                                                trackBlock.getTrackType());
        }
        GameObject newObject = UnityEngine.Object.Instantiate(factoryObject);

        placeBlockInView(newObject, x, y);
        //rotate it so it matches the data backing.
        Rotater rotater = newObject.GetComponent <Rotater>();

        rotater.buildArray();
        rotater.parent = this;
        rotater.x      = x;
        rotater.y      = y;
        rotater.name   = String.Format("{0},{1}", x, y);
        bool ok;

        TrackEnds[] rotatedArray = trackBlock.getTrackEnds();
//		StringBuilder logBuilder = new StringBuilder(100);
//		for(int i = 0; i < rotatedArray.Length; i++) {
//			if (i != 0){
//				logBuilder.Append(',');
//			}
//			logBuilder.Append(rotatedArray[i]);
//		}
//		Debug.Log(logBuilder);
//		Debug.Log(trackBlock.getTrackType());
        int offset = 0;

        do
        {
            ok = true;
            for (int i = 0; i < 4; i++)
            {
                if (rotatedArray[i] != rotater.ends[(i + offset) % 4])
                {
                    ok = false;
                    break;
                }
            }
            if (!ok)
            {
                offset++;
                DoRotate(rotater, true, true);
//				Debug.Log("Roated " + newObject + " clockwize");
            }
        } while (offset < 4 && !ok);
        //I sure hope it is rotated correctly by now....
        rotater.rotationOffset = offset;
        return(newObject);
    }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     this._levelController = GameObject.FindObjectOfType<LevelController>();
     this._fader = this.GetComponent<Fader>();
     this._collider = this.GetComponent<Collider2D>();
     this._renderer = this.GetComponent<Renderer>();
     this.state = TargetState.UNHIT;
     this._rotater = GetComponent<Rotater>();
     if (!this._rotater) this._rotater = this.gameObject.AddComponent<Rotater>(); //testing
     this._originalRotation = this.transform.rotation;
     _missiles = this.GetComponentsInChildren<Missile>();
     _flash = Camera.main.GetComponent<ColorFlash>();
 }
Exemplo n.º 10
0
    // float t = 0;

    // Initializes references
    void Awake()
    {
        rb       = GetComponent <Rigidbody2D>();
        animator = GetComponent <Animator>();
        rotater  = GetComponent <Rotater>();
    }
Exemplo n.º 11
0
    private void OnEnable()
    {
        rotater = GetComponent <Rotater>();

        handler = GetComponent <AsteroidClickHandler>();
    }