Esempio n. 1
0
        /// <include file='Doc/Wrappers.xml' path='docs/method[@name="Stat"]/*'/>
        public override StatStruct Stat(string path, StreamStatOptions options, StreamContext context, bool streamStat)
        {
            StatStruct invalid = new StatStruct();

            invalid.st_size = -1;
            Debug.Assert(path != null);

            // Note: path is already absolute w/o the scheme, the permissions have already been checked.
            return(HandleNewFileSystemInfo(invalid, path, (p) =>
            {
                FileSystemInfo info = null;

                info = new DirectoryInfo(p);
                if (!info.Exists)
                {
                    info = new FileInfo(p);
                    if (!info.Exists)
                    {
                        return invalid;
                    }
                }

                return BuildStatStruct(info, info.Attributes, p);
            }));
        }
Esempio n. 2
0
    public override StatStruct SaveState()
    {
        StatStruct s = new StatStruct();

        s.dir = dir;
        return(s);
    }
Esempio n. 3
0
    public override void LoadState(StatStruct s)
    {
        dir = s.dir;

        //transform.position = GameObject.FindWithTag("Ground").transform.position + new Vector3(0,5);
        //transform.position = transform.position + new Vector3(0,5);
    }
Esempio n. 4
0
    public virtual StatStruct SaveState()
    {
        StatStruct s = new StatStruct();

        s.dir = dir;
        return(s);
    }
Esempio n. 5
0
 public bool GetStatData(int index, out StatStruct statData)
 {
     if (statList.TryGetValue(index, out statData) == false)
     {
         Debug.LogWarning("not existed Data: " + index.ToString());
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
 // Start is called before the first frame update
 void Start()
 {
     stats     = new StatStruct();
     stats.dir = true;
     stats.dX  = dX;
     stats.dY  = dY;
     createEnemy();
     playerobj = GameObject.FindGameObjectWithTag("Plyr");
     plyrInit  = playerobj.GetComponent <PlayerS>();
     prevW     = plyrInit.wType;
 }
Esempio n. 7
0
        /// <include file='Doc/Streams.xml' path='docs/method[@name="Stat"]/*'/>
        public virtual StatStruct Stat()
        {
            if (this.Wrapper != null)
            {
                return(this.Wrapper.Stat(OpenedPath, StreamStatOptions.Empty, StreamContext.Default, true));
            }

            PhpException.Throw(PhpError.Warning, CoreResources.GetString("wrapper_op_unsupported", "Stat"));
            StatStruct rv = new StatStruct();

            rv.st_size = -1;
            return(rv);
        }
Esempio n. 8
0
        /// <summary>
        /// Stat the path coming from ResolvePath (file:// wrapper expects path w/o the scheme).
        /// </summary>
        /// <param name="path"></param>
        /// <param name="url"></param>
        /// <param name="wrapper"></param>
        /// <param name="quiet"></param>
        /// <returns>True if stat was successfuly added into cache.</returns>
        private static bool StatInternalStat(string path, string url, StreamWrapper wrapper, bool quiet)
        {
            StatStruct stat = wrapper.Stat(path, quiet ? StreamStatOptions.Quiet : StreamStatOptions.Empty, StreamContext.Default, false);

            if (stat.st_size >= 0)
            {
                statCacheUrl = url;
                statCache    = stat;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
    void createEnemy()
    {
        if (curType == mType)
        {
            return;
        }

        Debug.Log("Changing Enemy!");

        if (minion != null)
        {
            stats = minion.SaveState();
        }
        Destroy(minion);
        if (mType == 0)
        {
            minion    = gameObject.AddComponent <Slime>();
            minion.dX = dX;
            minion.dY = dY;
            //minion.GetComponent<Rigidbody2D>().gravityScale = 1;
        }
        else if (mType == 1)
        {
            minion    = gameObject.AddComponent <Fish>();
            minion.dX = dX * 2;
            minion.dY = dY * 2;
            //minion.GetComponent<Rigidbody2D>().gravityScale = 4;
        }
        else if (mType == 2)
        {
            minion    = gameObject.AddComponent <Bird>();
            minion.dX = dX * 1.5f;
            minion.dY = dY * 1.5f;
        }
        else
        {
            minion    = gameObject.AddComponent <Enemy>();
            minion.dX = 0;
            minion.dY = 0;
            minion.GetComponent <Rigidbody2D>().gravityScale = 1;
        }
        curType = mType;
        minion.LoadState(stats);
    }
Esempio n. 10
0
        /// <summary>
        /// Creates a <see cref="PhpArray"/> from the <see cref="StatStruct"/>
        /// copying the structure members into the array.
        /// </summary>
        /// <remarks>
        /// The resulting PhpArray has following associative keys in the given order
        /// (each has a corresponding numeric index starting from zero).
        /// As of ordering, first come all the numeric indexes and then come all the associative indexes.
        /// <list type="table">
        /// <item><term>dev</term><term>Drive number of the disk containing the file (same as st_rdev). </term></item>
        /// <item><term>ino</term><term>Number of the information node (the inode) for the file (UNIX-specific). On UNIX file systems, the inode describes the file date and time stamps, permissions, and content. When files are hard-linked to one another, they share the same inode. The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or NTFS file systems. </term></item>
        /// <item><term>mode</term><term>Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the path extension. </term></item>
        /// <item><term>nlink</term><term>Always 1 on non-NTFS file systems. </term></item>
        /// <item><term>uid</term><term>Numeric identifier of user who owns file (UNIX-specific). This field will always be zero on Windows NT systems. A redirected file is classified as a Windows NT file. </term></item>
        /// <item><term>gid</term><term>Numeric identifier of group that owns file (UNIX-specific) This field will always be zero on Windows NT systems. A redirected file is classified as a Windows NT file. </term></item>
        /// <item><term>rdev</term><term>Drive number of the disk containing the file (same as st_dev). </term></item>
        /// <item><term>size</term><term>Size of the file in bytes; a 64-bit integer for _stati64 and _wstati64 </term></item>
        /// <item><term>atime</term><term>Time of last access of file. Valid on NTFS but not on FAT formatted disk drives. Gives the same </term></item>
        /// <item><term>mtime</term><term>Time of last modification of file. </term></item>
        /// <item><term>ctime</term><term>Time of creation of file. Valid on NTFS but not on FAT formatted disk drives. </term></item>
        /// <item><term>blksize</term><term>Always -1 on non-NTFS file systems. </term></item>
        /// <item><term>blocks</term><term>Always -1 on non-NTFS file systems. </term></item>
        /// </list>
        /// </remarks>
        /// <param name="stat">A <see cref="StatStruct"/> returned by a stream wrapper.</param>
        /// <returns>A <see cref="PhpArray"/> in the format of the <c>stat()</c> PHP function.</returns>
        static PhpArray BuildStatArray(StatStruct stat)
        {
            // An unitialized StatStruct means an error.
            if (stat.st_ctime == 0)
            {
                return(null);
            }
            var result = new PhpArray(26);

            result.Add(0, (int)stat.st_dev);                     // device number
            result.Add(1, (int)stat.st_ino);                     // inode number
            result.Add(2, (int)stat.st_mode);                    // inode protection mode
            result.Add(3, (int)stat.st_nlink);                   // number of links
            result.Add(4, (int)stat.st_uid);                     // userid of owner
            result.Add(5, (int)stat.st_gid);                     // groupid of owner
            result.Add(6, (int)stat.st_rdev);                    // device type, if inode device -1
            result.Add(7, (int)stat.st_size);                    // size in bytes (reset by caller)
            result.Add(8, unchecked ((int)stat.st_atime));       // time of last access (unix timestamp)
            result.Add(9, unchecked ((int)stat.st_mtime));       // time of last modification (unix timestamp)
            result.Add(10, unchecked ((int)stat.st_ctime));      // time of last change (unix timestamp)
            result.Add(11, (int)-1);                             // blocksize of filesystem IO (-1)
            result.Add(12, (int)-1);                             // number of blocks allocated  (-1)

            result.Add("dev", (int)stat.st_dev);                 // device number
            result.Add("ino", (int)stat.st_ino);                 // inode number
            result.Add("mode", (int)stat.st_mode);               // inode protection mode
            result.Add("nlink", (int)stat.st_nlink);             // number of links
            result.Add("uid", (int)stat.st_uid);                 // userid of owner
            result.Add("gid", (int)stat.st_gid);                 // groupid of owner
            result.Add("rdev", (int)stat.st_rdev);               // device type, if inode device -1
            result.Add("size", (int)stat.st_size);               // size in bytes (reset by caller)
            result.Add("atime", unchecked ((int)stat.st_atime)); // time of last access (unix timestamp)
            result.Add("mtime", unchecked ((int)stat.st_mtime)); // time of last modification (unix timestamp)
            result.Add("ctime", unchecked ((int)stat.st_ctime)); // time of last change (unix timestamp)
            result.Add("blksize", (int)-1);                      // blocksize of filesystem IO (-1)
            result.Add("blocks", (int)-1);                       // number of blocks allocated  (-1)

            return(result);
        }
Esempio n. 11
0
    public InventoryItem GenerateNewItem()
    {
        ItemQuality quality;
        ItemType    type = ItemType.SwingBlade;

        StatStruct[] stats;
        string       name = string.Empty;
        int          size;
        var          qualityRoll = Random.Range(0, 100);

        if (qualityRoll <= 50)
        {
            quality = ItemQuality.Rare;
        }
        else if (qualityRoll > 50 && qualityRoll <= 70)
        {
            quality = ItemQuality.Legendary;
        }
        else if (qualityRoll > 70 && qualityRoll <= 80)
        {
            quality = ItemQuality.Set;
        }
        else
        {
            return(default(InventoryItem));
        }

        bool flag = false;

        while (!flag) // check if there is a name for an item with such type and quality. If there is no name for that time, then we'll look for another type
        {
            var itemTypeRoll = Random.Range(0, 41);
            type = (ItemType)itemTypeRoll;

            if (quality == ItemQuality.Rare)
            {
                flag = true;
            }
            else if (namesList.Any(z => z.Quality == quality && z.Type == type))
            {
                flag = true;
            }
        }

        switch (type) //only accessories have 1 slot size
        {
        case ItemType.Amulet:
        case ItemType.Belt:
        case ItemType.MightyBelt:
        case ItemType.Ring:
            size = 1;
            break;

        default:
            size = 2;
            break;
        }

        if (quality != ItemQuality.Rare) // Rare items have another logic for name generation
        {
            var possibleNames = namesList.Where(z => z.Quality == quality && z.Type == type).ToList();
            var nameRoll      = Random.Range(0, possibleNames.Count);
            name = possibleNames[nameRoll].Name;
        }

        var amountOfStats = Random.Range(2, 7);

        if (quality == ItemQuality.Legendary || quality == ItemQuality.Set)
        {
            amountOfStats = 6;
        }

        stats = new StatStruct[amountOfStats];
        for (int i = 0; i < amountOfStats; i++)
        {
            CharacterStat stat = CharacterStat.MainStat;
            flag = false;
            while (!flag) // if item can't have that type of stat for some reason, then we'll generate another stat until we'll have an appropriate one
            {
                var statRoll = Random.Range(0, 19);
                stat = (CharacterStat)statRoll;

                if ((stat == CharacterStat.Intelligence || stat == CharacterStat.Dexterity || stat == CharacterStat.Strength) &&
                    stats.Any(z => z.stat == CharacterStat.Dexterity || z.stat == CharacterStat.Intelligence || z.stat == CharacterStat.Strength))
                {
                    continue;
                }
                if (!stats.Any(z => z.stat == stat))
                {
                    flag = true;
                }
            }
            double amountofStat  = 0;
            int    maxStatAmount = 0;
            switch (stat)
            {
            case CharacterStat.Block:
            case CharacterStat.CritChance:
                maxStatAmount = Convert.ToInt32(Math.Pow(Account.CurrentAccount.GetCurrentHero().Level, 2) / 2);
                amountofStat  = Random.Range(maxStatAmount / 3 * 2, maxStatAmount);
                break;

            case CharacterStat.BotDamage:
                maxStatAmount =
                    Convert.ToInt32(Math.Pow(100 + Account.CurrentAccount.GetCurrentHero().Level, 2));
                amountofStat = Random.Range(maxStatAmount / 3 * 2, maxStatAmount) * 0.001;
                break;

            case CharacterStat.CritDamage:
                break;

            case CharacterStat.ResistAll:
                break;

            case CharacterStat.Life:
                amountofStat = Random.Range(1, Account.CurrentAccount.GetCurrentHero().Level) * 0.5;
                break;

            case CharacterStat.Regen:
                break;

            case CharacterStat.LifePerHit:
                break;

            case CharacterStat.Sockets:     //item can contain no more than 3 sockets
                maxStatAmount = Convert.ToInt32(1 + Account.CurrentAccount.GetCurrentHero().Level / 20) > 3
                        ? 3
                        : Convert.ToInt32(1 + Account.CurrentAccount.GetCurrentHero().Level / 20);
                amountofStat = Random.Range(1, maxStatAmount);
                break;

            case CharacterStat.DamageAgainstElites:
                break;

            case CharacterStat.DamageReduction:
                break;

            case CharacterStat.ExtraGold:
                break;

            case CharacterStat.ExtraExperience:
                break;

            case CharacterStat.Thorns:
                break;

            case CharacterStat.BotAttackSpeed:
                break;

            case CharacterStat.Vitality:     //all 'main' and vitality stats have the same logic for rolling
            case CharacterStat.Intelligence:
            case CharacterStat.Strength:
            case CharacterStat.Dexterity:
                maxStatAmount = Convert.ToInt32((Math.Pow(Account.CurrentAccount.GetCurrentHero().Level, 2)));
                amountofStat  = Random.Range(maxStatAmount / 3 * 2, maxStatAmount);
                if (amountofStat == 0)
                {
                    amountofStat = 1;
                }
                break;
            }
            stats[i] = new StatStruct()
            {
                stat = stat, StatAmount = amountofStat
            };
        }

        var Armor = 0;

        if (type != ItemType.Amulet && type != ItemType.Belt && type != ItemType.Ring && type != ItemType.MightyBelt) //there is no armor on accessories
        {
            Armor = Random.Range((Account.CurrentAccount.GetCurrentHero().Level *5 / 3) * 2,
                                 Account.CurrentAccount.GetCurrentHero().Level *5);
        }

        var sellValue = 0;

        switch (quality)
        {
        case ItemQuality.Rare:
            sellValue = Convert.ToInt32((10 + stats.Length * 5) * Account.CurrentAccount.GetCurrentHero().Level *0.1);
            break;

        case ItemQuality.Legendary:
            sellValue = Convert.ToInt32((25 + stats.Length * 5) * Account.CurrentAccount.GetCurrentHero().Level * 0.1);
            break;

        case ItemQuality.Set:
            sellValue = Convert.ToInt32((50 + stats.Length * 5) * Account.CurrentAccount.GetCurrentHero().Level * 0.1);
            break;
        }

        return(new InventoryItem(name, quality, type, size, stats, Armor, sellValue));
    }
Esempio n. 12
0
 public virtual void LoadState(StatStruct s)
 {
     dir = s.dir;
 }
Esempio n. 13
0
 public override void LoadState(StatStruct s)
 {
     dir = s.dir;
 }
Esempio n. 14
0
 private static void Clear()
 {
     statCache    = new StatStruct();
     statCacheUrl = null;
 }
Esempio n. 15
0
    public InventoryItem GenerateNewItem()
    {
        ItemQuality quality;
        ItemType type = ItemType.SwingBlade;
        StatStruct[] stats;
        string name = string.Empty;
        int size;
        var qualityRoll = Random.Range(0, 100);
        if (qualityRoll <= 50)
            quality = ItemQuality.Rare;
        else if(qualityRoll > 50 && qualityRoll <= 70)
            quality = ItemQuality.Legendary;
        else if (qualityRoll > 70 && qualityRoll <= 80)
            quality = ItemQuality.Set;
        else
            return default(InventoryItem);

        bool flag = false;
        while (!flag) // check if there is a name for an item with such type and quality. If there is no name for that time, then we'll look for another type
        {
            var itemTypeRoll = Random.Range(0, 41);
            type = (ItemType) itemTypeRoll;

            if (quality == ItemQuality.Rare)
                flag = true;
            else if (namesList.Any(z => z.Quality == quality && z.Type == type))
                flag = true;
        }

        switch (type) //only accessories have 1 slot size
        {
            case ItemType.Amulet:
            case ItemType.Belt:
            case ItemType.MightyBelt:
            case ItemType.Ring:
                size = 1;
                break;
            default:
                size = 2;
                break;
        }

        if (quality != ItemQuality.Rare) // Rare items have another logic for name generation
        {
            var possibleNames = namesList.Where(z => z.Quality == quality && z.Type == type).ToList();
            var nameRoll = Random.Range(0, possibleNames.Count);
            name = possibleNames[nameRoll].Name;
        }

        var amountOfStats = Random.Range(2, 7);
        if (quality == ItemQuality.Legendary || quality == ItemQuality.Set)
            amountOfStats = 6;

        stats = new StatStruct[amountOfStats];
        for (int i = 0; i < amountOfStats; i++)
        {
            CharacterStat stat = CharacterStat.MainStat;
            flag = false;
            while (!flag) // if item can't have that type of stat for some reason, then we'll generate another stat until we'll have an appropriate one
            {
                var statRoll = Random.Range(0, 19);
                stat = (CharacterStat) statRoll;

                if ((stat == CharacterStat.Intelligence || stat == CharacterStat.Dexterity ||stat == CharacterStat.Strength) &&
                    stats.Any(z => z.stat == CharacterStat.Dexterity || z.stat == CharacterStat.Intelligence || z.stat == CharacterStat.Strength))
                    continue;
                if (!stats.Any(z => z.stat == stat))
                    flag = true;
            }
            double amountofStat = 0;
            int maxStatAmount = 0;
            switch (stat)
            {
                case CharacterStat.Block:
                case CharacterStat.CritChance:
                    maxStatAmount = Convert.ToInt32(Math.Pow(Account.CurrentAccount.GetCurrentHero().Level, 2)/2);
                    amountofStat = Random.Range(maxStatAmount/3 * 2, maxStatAmount);
                    break;
                case CharacterStat.BotDamage:
                    maxStatAmount =
                        Convert.ToInt32(Math.Pow(100 + Account.CurrentAccount.GetCurrentHero().Level, 2));
                    amountofStat = Random.Range(maxStatAmount/3*2, maxStatAmount)*0.001;
                    break;
                case CharacterStat.CritDamage:
                    break;
                case CharacterStat.ResistAll:
                    break;
                case CharacterStat.Life:
                    amountofStat = Random.Range(1, Account.CurrentAccount.GetCurrentHero().Level)*0.5;
                    break;
                case CharacterStat.Regen:
                    break;
                case CharacterStat.LifePerHit:
                    break;
                case CharacterStat.Sockets: //item can contain no more than 3 sockets
                    maxStatAmount = Convert.ToInt32(1 + Account.CurrentAccount.GetCurrentHero().Level/20) > 3
                        ? 3
                        : Convert.ToInt32(1 + Account.CurrentAccount.GetCurrentHero().Level/20);
                    amountofStat = Random.Range(1, maxStatAmount);
                    break;
                case CharacterStat.DamageAgainstElites:
                    break;
                case CharacterStat.DamageReduction:
                    break;
                case CharacterStat.ExtraGold:
                    break;
                case CharacterStat.ExtraExperience:
                    break;
                case CharacterStat.Thorns:
                    break;
                case CharacterStat.BotAttackSpeed:
                    break;
                case CharacterStat.Vitality: //all 'main' and vitality stats have the same logic for rolling
                case CharacterStat.Intelligence:
                case CharacterStat.Strength:
                case CharacterStat.Dexterity:
                    maxStatAmount = Convert.ToInt32((Math.Pow(Account.CurrentAccount.GetCurrentHero().Level, 2)));
                    amountofStat = Random.Range(maxStatAmount/3*2, maxStatAmount);
                    if (amountofStat == 0)
                        amountofStat = 1;
                    break;
            }
            stats[i] = new StatStruct() { stat = stat, StatAmount = amountofStat };
        }

        var Armor = 0;
        if (type != ItemType.Amulet && type != ItemType.Belt && type != ItemType.Ring && type != ItemType.MightyBelt) //there is no armor on accessories
            Armor = Random.Range((Account.CurrentAccount.GetCurrentHero().Level*5/3)*2,
            Account.CurrentAccount.GetCurrentHero().Level*5);

        var sellValue = 0;
        switch (quality)
        {
            case ItemQuality.Rare:
                sellValue = Convert.ToInt32((10 + stats.Length*5)*Account.CurrentAccount.GetCurrentHero().Level*0.1);
                break;
            case ItemQuality.Legendary:
                sellValue = Convert.ToInt32((25 + stats.Length * 5) * Account.CurrentAccount.GetCurrentHero().Level * 0.1);
                break;
            case ItemQuality.Set:
                sellValue = Convert.ToInt32((50 + stats.Length * 5) * Account.CurrentAccount.GetCurrentHero().Level * 0.1);
                break;
        }

        return new InventoryItem(name, quality, type, size, stats, Armor, sellValue);
    }
Esempio n. 16
0
 public InventoryItem(string name, ItemQuality quality, ItemType type, int size, StatStruct[] stats, int armor, int sellValue)
 {
     Name = name;
     Quality = quality;
     Type = type;
     Size = size;
     itemStats = stats;
     Armor = armor;
     SellValue = sellValue;
 }