// Camera mainCamera;
    // Start is called before the first frame update
    void Start()
    {
        GameObject player = GameObject.Find("player");

        info = player.GetComponent <playerControls>();

        // mainCamera = Camera.main;

        Transform textObj = transform.Find("Points");

        score = textObj.GetComponent <Text>();

        Transform repImg   = transform.Find("Repel");
        RawImage  repelraw = repImg.GetComponent <RawImage>();

        repel           = repelraw.GetComponent <RectTransform>();
        fullSizeRep     = repel.sizeDelta.x;
        repel.sizeDelta = new Vector2(0, repel.sizeDelta.y);

        Transform capImg      = transform.Find("Capacity");
        RawImage  capacityraw = capImg.GetComponent <RawImage>();

        capacity           = capacityraw.GetComponent <RectTransform>();
        fullSizeCap        = capacity.sizeDelta.x;
        capacity.sizeDelta = new Vector2(0, capacity.sizeDelta.y);

        Transform endBack    = transform.Find("endingBack");
        RawImage  endBackImg = endBack.GetComponent <RawImage>();

        endBackImg.enabled = false;

        currentHighest = info.points;
        score.text     = "Highest Scorer: " + highestScorer + "\t\t" + "Highest Score: " + currentHighest + "\t\t" + "Your Score: " + info.points;
    }
    // Use this for initialization
    void Awake()
    {
        player = GetComponent <playerControls>();

        width  = GetComponent <BoxCollider2D>().bounds.extents.x - 0.01f;
        height = GetComponent <BoxCollider2D>().bounds.extents.y + 0.02f;
    }
Exemple #3
0
    public void ConfirmStats(playerControls player)
    {
        player.creatingCharacter = false;

        for (int i = 0; i < stat1; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(1);
        }
        for (int i = 0; i < stat2; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(2);
        }
        for (int i = 0; i < stat3; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(3);
        }

        for (int i = 0; i < stat4; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(4);
        }
        for (int i = 0; i < stat5; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(5);
        }
        for (int i = 0; i < stat6; i++) //for all the points we put into this stat, do this and repeat for 2 to 6
        {
            player.RaiseStat(6);
        }
    }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        cHealth = fullHealth;

        controlMovement = GetComponent <playerControls>();

        //HUD
        healthBar.maxValue = fullHealth;
        healthBar.value    = fullHealth;

        damaged = false;
    }
Exemple #5
0
    void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == customTags.Bullet || other.transform.tag == customTags.Enemies)
        {
            return;
        }


        if (other.transform.tag == customTags.Player)
        {
            devLog.WriteConsole(customStrings.hitPlayer);
            playerControls player = other.GetComponent <playerControls>();
            player.applyDamage(gm.enemyDamage);
        }
        selfDestruct();
    }
Exemple #6
0
        public void Move(playerControls action)
        {
            switch (action)
            {
            case playerControls.Up:
                if (this.center.Y <= 0)
                {
                    break;
                }
                base.center   = new Point(center.X, center.Y - 6);
                base.hitbox.Y = center.Y;
                break;

            case playerControls.Down:
                if (this.center.Y >= Screen.PrimaryScreen.WorkingArea.Bottom)
                {
                    break;
                }
                base.center   = new Point(center.X, center.Y + 6);
                base.hitbox.Y = center.Y;
                break;

            case playerControls.Left:
                if (this.center.X <= 0)
                {
                    break;
                }
                base.center   = new Point(center.X - 6, center.Y);
                base.hitbox.X = center.X;
                break;

            case playerControls.Right:
                if (this.center.X >= Screen.PrimaryScreen.WorkingArea.Right - this.width)
                {
                    break;
                }
                base.center   = new Point(center.X + 6, center.Y);
                base.hitbox.X = center.X;
                break;
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        GameObject ground      = GameObject.Find("ground");
        tileSet    groundtiles = ground.GetComponent <tileSet>();

        total = groundtiles.total;

        GameObject foliage = GameObject.Find("foliage");

        fscript   = foliage.GetComponent <flowerSet>();
        flowerRef = foliage.GetComponent <Tilemap>();

        GameObject canvas = GameObject.Find("Canvas");

        scoreB = canvas.GetComponent <scoreboard>();

        player = GameObject.Find("player");
        pInfo  = player.GetComponent <playerControls>();

        gauges = new int[children];
        scores = new int[children];


        for (int i = 0; i < children; i++)
        {
            Instantiate(enemies, transform);
            gauges[i] = 0;
            scores[i] = 0;
        }
        startPosX = fscript.startX + 2.5f;
        startPosY = fscript.startY + 2.5f;
        for (int i = 0; i < transform.childCount; i++)
        {
            Transform child = transform.GetChild(i);
            child.transform.position = new Vector3(startPosX, startPosY, -1);
        }
    }
Exemple #8
0
 private void Awake()
 {
     player       = GetComponent <playerControls>();
     inputActions = new PlayerInputActions();
 }
 private void Start()
 {
     player = FindObjectOfType <playerControls>();
 }
 void Start()
 {
     body          = GetComponent <Rigidbody>();
     currentHealth = maxHealth;
     instance      = this;
 }
Exemple #11
0
 public static void KillPlayer(playerControls player)
 {
     Destroy(player.gameObject);
 }
Exemple #12
0
    // Start is called before the first frame update
    void Start()
    {
        Tilemap map = GetComponent <Tilemap>();

        range = 100;

        GameObject ground      = GameObject.Find("ground");
        tileSet    groundtiles = ground.GetComponent <tileSet>();

        total = groundtiles.total;

        player = GameObject.Find("player");
        pInfo  = player.GetComponent <playerControls>();


        small = new Tile[5] {
            sFlower1, sFlower2, sFlower3, mushroom, sRock
        };
        big = new Tile[5] {
            bFlower1, bFlower2, bFlower3, sBush, bRock
        };
        unuseable = new Tile[4] {
            unuseS, unusebigR, unusebigP, unusebigL
        };
        availablegrid = new int[groundtiles.total, groundtiles.total];
        flowerTiles   = new int[groundtiles.total, groundtiles.total];
        for (int y = 0; y < groundtiles.total; y++)
        {
            for (int x = 0; x < groundtiles.total; x++)
            {
                availablegrid[y, x] = 1;
                flowerTiles[y, x]   = 0;
            }
        }

        startX = Random.Range((groundtiles.total / 4), (groundtiles.total / 4) * 3);
        startY = Random.Range((groundtiles.total / 4), (groundtiles.total / 2));
        bool hivePlaced = false;

        while (!hivePlaced)
        {
            if (groundtiles.grid[startY, startX] == 1 && groundtiles.grid[startY, startX + 1] == 1 && groundtiles.grid[startY, startX + 2] == 1 && groundtiles.grid[startY, startX + 3] == 1 && groundtiles.grid[startY, startX + 4] == 1 &&
                groundtiles.grid[startY + 1, startX] == 1 && groundtiles.grid[startY + 1, startX + 1] == 1 && groundtiles.grid[startY + 1, startX + 2] == 1 && groundtiles.grid[startY + 1, startX + 3] == 1 && groundtiles.grid[startY + 1, startX + 4] == 1 &&
                groundtiles.grid[startY + 2, startX] == 1 && groundtiles.grid[startY + 2, startX + 1] == 1 && groundtiles.grid[startY + 2, startX + 2] == 1 && groundtiles.grid[startY + 2, startX + 3] == 1 && groundtiles.grid[startY + 2, startX + 4] == 1 &&
                groundtiles.grid[startY + 3, startX] == 1 && groundtiles.grid[startY + 3, startX + 1] == 1 && groundtiles.grid[startY + 3, startX + 2] == 1 && groundtiles.grid[startY + 3, startX + 3] == 1 && groundtiles.grid[startY + 3, startX + 4] == 1 &&
                groundtiles.grid[startY + 4, startX] == 1 && groundtiles.grid[startY + 4, startX + 1] == 1 && groundtiles.grid[startY + 4, startX + 2] == 1 && groundtiles.grid[startY + 4, startX + 3] == 1 && groundtiles.grid[startY + 4, startX + 4] == 1)
            {
                for (int y = 0; y < 5; y++)
                {
                    for (int x = 0; x < 5; x++)
                    {
                        availablegrid[startY + y, startX + x] = 0;
                    }
                }

                map.SetTile(new Vector3Int(startX, startY, 0), hive);
                hivePlaced = true;
            }
            else if (startX < groundtiles.total - 3)
            {
                startX += 1;
            }
            else
            {
                startX  = 0;
                startY += 1;
            }
        }

        for (int i = 0; i < children; i++)
        {
            Instantiate(worm, transform);
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            Transform child       = transform.GetChild(i);
            int       x           = Random.Range(0, (groundtiles.total / 4) * 3);
            int       y           = Random.Range(0, (groundtiles.total / 4) * 3);
            bool      childPlaced = false;
            while (!childPlaced)
            {
                if (y - 1 >= 0 && x - 1 >= 0 && y + 1 < groundtiles.total && x + 1 < groundtiles.total &&
                    groundtiles.grid[y, x] == 1 && availablegrid[y, x] == 1)
                {
                    child.localPosition         = new Vector3Int(x, y, 0);
                    availablegrid[y, x]         = 0;
                    availablegrid[y - 1, x + 1] = 0;
                    availablegrid[y + 1, x - 1] = 0;
                    availablegrid[y - 1, x - 1] = 0;
                    availablegrid[y + 1, x + 1] = 0;
                    childPlaced = true;
                }
                else if (x < groundtiles.total)
                {
                    x += 1;
                }
                else
                {
                    x  = 0;
                    y += 1;
                }
            }
        }

        Debug.Log(startX);
        Debug.Log(startY);

        for (int y = 0; y < groundtiles.total; y++)
        {
            for (int x = 0; x < groundtiles.total; x++)
            {
                if (availablegrid[y, x] == 1)
                {
                    int choice = Random.Range(0, range);
                    if ((y + 1 < groundtiles.total && availablegrid[y + 1, x] == 1 &&
                         x + 1 < groundtiles.total && availablegrid[y, x + 1] == 1 && availablegrid[y + 1, x + 1] == 1) &&
                        ((choice < 30 && groundtiles.grid[y, x] == 0 && groundtiles.grid[y + 1, x] == 0 && groundtiles.grid[y, x + 1] == 0 && groundtiles.grid[y + 1, x + 1] == 0) ||
                         (choice < 10 && groundtiles.grid[y, x] == 1 && groundtiles.grid[y + 1, x] == 1 && groundtiles.grid[y, x + 1] == 1 && groundtiles.grid[y + 1, x + 1] == 1)))
                    {
                        int which;
                        if (choice >= 1 && groundtiles.grid[y, x] == 1 && groundtiles.grid[y + 1, x] == 1 && groundtiles.grid[y, x + 1] == 1 && groundtiles.grid[y + 1, x + 1] == 1)
                        {
                            which = Random.Range(3, 5);
                            map.SetTile(new Vector3Int(x, y, 0), big[which]);
                        }
                        else
                        {
                            which = Random.Range(0, 3);
                            map.SetTile(new Vector3Int(x, y, 0), big[which]);
                        }
                        for (int plusy = 0; plusy < 2; plusy++)
                        {
                            for (int plusx = 0; plusx < 2; plusx++)
                            {
                                availablegrid[y + plusy, x + plusx] = 0;
                                if (which >= 0 && which < 3)
                                {
                                    flowerTiles[y, x] = 1;
                                    flowerNumbers    += 1;
                                }
                            }
                        }
                    }
                    else if ((groundtiles.grid[y, x] == 0 && choice < 80) || (groundtiles.grid[y, x] == 1 && choice < 15))
                    {
                        if (choice >= 4 && groundtiles.grid[y, x] == 1)
                        {
                            map.SetTile(new Vector3Int(x, y, 0), small[Random.Range(3, 5)]);
                        }
                        else
                        {
                            map.SetTile(new Vector3Int(x, y, 0), small[Random.Range(0, 3)]);
                            flowerTiles[y, x] = 1;
                            flowerNumbers    += 1;
                        }
                        availablegrid[y, x] = 0;
                    }
                    else if ((groundtiles.grid[y, x] == 1 && y + 1 < groundtiles.total && groundtiles.grid[y + 1, x] == 1 && availablegrid[y + 1, x] == 1 && y + 2 < groundtiles.total && groundtiles.grid[y + 2, x] == 1 && availablegrid[y + 2, x] == 1 &&
                              x + 1 < groundtiles.total && groundtiles.grid[y, x + 1] == 1 && availablegrid[y, x + 1] == 1 && groundtiles.grid[y + 1, x + 1] == 1 && availablegrid[y + 1, x + 1] == 1 && groundtiles.grid[y + 2, x + 1] == 1 && availablegrid[y + 2, x + 1] == 1 &&
                              x + 2 < groundtiles.total && groundtiles.grid[y, x + 2] == 1 && availablegrid[y, x + 2] == 1 && groundtiles.grid[y + 1, x + 2] == 1 && availablegrid[y + 1, x + 2] == 1 && groundtiles.grid[y + 2, x + 2] == 1 && availablegrid[y + 2, x + 2] == 1) &&
                             choice >= 50 && choice < 55)
                    {
                        int whichBig = Random.Range(0, 3);
                        if (whichBig == 0)
                        {
                            map.SetTile(new Vector3Int(x, y, 0), bBush);
                            for (int plusy = 0; plusy < 3; plusy++)
                            {
                                for (int plusx = 0; plusx < 3; plusx++)
                                {
                                    availablegrid[y + plusy, x + plusx] = 0;
                                }
                            }
                        }
                        else if (whichBig == 1)
                        {
                            map.SetTile(new Vector3Int(x, y, 0), wide);
                            for (int plusy = 0; plusy < 2; plusy++)
                            {
                                for (int plusx = 0; plusx < 3; plusx++)
                                {
                                    availablegrid[y + plusy, x + plusx] = 0;
                                }
                            }
                        }
                        else
                        {
                            map.SetTile(new Vector3Int(x, y, 0), tall);
                            for (int plusy = 0; plusy < 3; plusy++)
                            {
                                for (int plusx = 0; plusx < 2; plusx++)
                                {
                                    availablegrid[y + plusy, x + plusx] = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            Transform child = transform.GetChild(i);
            int       x     = (int)child.transform.position.x;
            int       y     = (int)child.transform.position.y;
            availablegrid[y - 1, x + 1] = 1;
            availablegrid[y + 1, x - 1] = 1;
            availablegrid[y - 1, x - 1] = 1;
            availablegrid[y + 1, x + 1] = 1;
        }
    }
Exemple #13
0
 //Get input code
 private void Awake()
 {
     playerCont = gameObject.GetComponent <playerControls>();
 }
Exemple #14
0
 // Start is called before the first frame update
 void Start()
 {
     placon = GetComponent <playerControls>();
 }