Ejemplo n.º 1
0
    static ItemType()
    {
        foreach (ItemType type in sheet)
        {
            if (type.code == null)
            {
                continue;
            }
            if (byCode.ContainsKey(type.code))
            {
                continue;
            }
            if (type.body)
            {
                type.bodyLoc1 = BodyLoc.GetIndex(type.bodyLoc1Code);
                type.bodyLoc2 = BodyLoc.GetIndex(type.bodyLoc2Code);
            }
            byCode.Add(type.code, type);
        }

        foreach (ItemType type in sheet)
        {
            if (type._equiv1 != null)
            {
                type.equiv1 = Find(type._equiv1);
            }
            if (type._equiv2 != null)
            {
                type.equiv2 = Find(type._equiv2);
            }
        }
    }
Ejemplo n.º 2
0
    static void SpawnPlayer(string className, Vector3 pos)
    {
        CharStatsInfo info   = CharStatsInfo.Find(className);
        var           player = new GameObject("Player");

        player.tag = "Player";
        player.transform.position = pos;
        var character = player.AddComponent <Character>();

        character.basePath       = @"data\global\chars";
        character.token          = info.token;
        character.weaponClass    = info.baseWClass;
        character.directionCount = 16;
        character.run            = true;
        character.walkSpeed      = 7;
        character.runSpeed       = 15;
        character.maxHealth      = 1000;
        character.health         = 1000;
        character.size           = 2;

        character.equip = player.AddComponent <Equipment>();
        Inventory.Create(player, 10, 4);
        var body = player.AddComponent <Rigidbody2D>();

        body.isKinematic = true;
        var collider = player.AddComponent <CircleCollider2D>();

        collider.radius = Iso.tileSizeY;
        var listenerObject = new GameObject("Audio Listener");

        listenerObject.AddComponent <AudioListener>();
        listenerObject.transform.SetParent(player.transform, true);
        listenerObject.transform.localPosition = new Vector3(0, 0, -1);

        PlayerController.instance.SetCharacter(character);

        foreach (var startingItem in info.startingItems)
        {
            if (startingItem.code == null)
            {
                continue;
            }

            var itemInfo = ItemInfo.Find(startingItem.code);
            for (int i = 0; i < startingItem.count; ++i)
            {
                var item = new Item(itemInfo);
                if (startingItem.loc != null)
                {
                    int loc = BodyLoc.GetIndex(startingItem.loc);
                    character.equip.Equip(item, loc);
                }
                else
                {
                    PlayerController.instance.Take(item);
                }
            }
        }
    }