예제 #1
0
        void Start()
        {
            PlayerStats = ScriptableObject.CreateInstance <Stats>();
            PlayerStats.SetStats(100, 5f, 5, 0.5f, 1.5f);
            gameObject.transform.localScale = new Vector3(PlayerStats.Scale, PlayerStats.Scale, 1f);

            originalHealth = PlayerStats.Health;
            originalSpeed  = PlayerStats.Speed;

            PlayerInventory = new Inventory();
            rb = gameObject.GetComponent <Rigidbody2D>();

            noDieTimer = dmgCooldown;

            inventoryWindow       = transform.FindChild("InventoryWindow").GetComponent <Canvas>();
            inventoryGridLayout   = inventoryWindow.GetComponentInChildren <GridLayoutGroup>();
            inventoryWindowActive = false;
            inventoryWindow.gameObject.SetActive(inventoryWindowActive);

            equipWindow       = transform.FindChild("EquipmentWindow").GetComponent <Canvas>();
            equipWindowActive = false;
            equipWindow.gameObject.SetActive(equipWindowActive);

            buttonPrefab = Resources.Load <GameObject>("InventoryItemButton");

            AutoEquipIfEmpty = true;
        }
        // Use this for initialization
        void Start()
        {
            EnemyStats = Stats.CreateInstance <Stats>();
            EnemyStats.SetStats(20, 4f, 10, 0.5f, Random.Range(1.2f, 2f));
            gameObject.transform.localScale = new Vector3(EnemyStats.Scale, EnemyStats.Scale, 1f);

            target = GameObject.FindGameObjectWithTag("Player").gameObject;

            if (roam)
            {
                patrol = false;
                stand  = false;
            }
            else if (patrol)
            {
                // Roam if nowhere to start patrol
                if (patrolPoints[0] == null)
                {
                    patrol = false;
                    roam   = false;

                    stand = true;
                }
                else
                {
                    transform.position = patrolPoints[0].position;
                    currentPoint       = 0;
                    roam  = false;
                    stand = false;
                }
            }
            else if (stand)
            {
                roam   = false;
                patrol = false;
            }
            else
            {
                stand = true;
            }

            myRigidbody = GetComponent <Rigidbody2D>();

            timeBetweenMoveCounter = Random.Range(timeBetweenMove * 0.75f, timeBetweenMove * 1.25f);
            timeToMoveCounter      = Random.Range(timeToMove * 0.75f, timeToMove * 1.25f);
        }