Ejemplo n.º 1
0
    private List <WeaponEntry> statusList; //武器切り替えに使うもの

    //初期化関数
    public void Initialize(GameObject usingObj)
    {
        BaseWeaponCommand[] command   = new BaseWeaponCommand[2];
        GameObject          weaponObj = usingObj.GetComponentInChildren <WeaponStatus>().gameObject;

        hodainGrubCommand     = weaponObj.AddComponent <HodainGrubCommand>();
        highHodainGrubCommand = weaponObj.AddComponent <HighHodainGrubCommand>();
        command[0]            = hodainGrubCommand;
        command[1]            = highHodainGrubCommand;
        for (int i = 0; i < command.Length; i++)
        {
            command[i].Initialize(weaponObj);
        }

        WeaponEntry[] weapon = new WeaponEntry[2];
        hodainGrubState     = weaponObj.AddComponent <HodainGrubState>();
        highHodainGrubState = weaponObj.AddComponent <HighHodainGrubState>();
        weapon[0]           = hodainGrubState;
        weapon[1]           = highHodainGrubState;
        for (int i = 0; i < weapon.Length; i++)
        {
            weapon[i].SubInitialize(weaponObj);
        }

        //サブ初期化
        weaponObj.GetComponentInChildren <WeaponStateMachine>().SubInitialize(weaponObj);

        //武器イメージとステートとの対応付け
        statusList = new List <WeaponEntry>();
        for (int i = 0; i < weapon.Length; i++)
        {
            statusList.Add(weapon[i]);
        }
    }
Ejemplo n.º 2
0
    public void CreateMenu(int id, GameObject weaponInstance)
    {
        gameObject.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0);

        currentLevelText.transform.parent.GetComponent <Button>().interactable = true;

        weapon = ObjectsHolder.ins.GetWeaponEntryWithId(id);

        weaponObject = weaponInstance;

        switch (weapon.type)
        {
        case ObjectType.turret:
            weaponImage.sprite = weaponSpriteArray[0];
            //weaponTitleText.text = "Turret";
            break;

        case ObjectType.freezebox:
            weaponImage.sprite = weaponSpriteArray[1];
            //weaponTitleText.text = "Freezer";
            break;

        case ObjectType.flamebox:
            weaponImage.sprite = weaponSpriteArray[2];
            //weaponTitleText.text = "Flamethrower";
            break;

        case ObjectType.shooterbox:
            weaponImage.sprite = weaponSpriteArray[3];
            //weaponTitleText.text = "Shooter";
            break;

        case ObjectType.wall:
            weaponImage.sprite = weaponSpriteArray[4];
            //weaponTitleText.text = "Wall";
            break;

        default:
            Debug.Log("WeaponType in CreateMenu defaulted");
            break;
        }

        currentLevelText.text = "Level " + weapon.level.ToString();

        sellAmountText.text = "$" + Mathf.RoundToInt(upgradeCost[weapon.type][weapon.level] / 2).ToString();

        if (weapon.level == 3)
        {
            currentLevelText.transform.parent.GetComponent <Button>().interactable = false;

            upgradeCostText.text = "MAX";
        }
        else
        {
            upgradeCostText.text = "$" + upgradeCost[weapon.type][weapon.level + 1].ToString();
        }
    }
    public void InstantiateWeapon()
    {
        WeaponEntry weapon = new WeaponEntry();

        GameObject createdWeapon = Instantiate(weaponsArray[holdingWeaponIndex], new Vector3(transform.position.x, transform.position.y, 0), Quaternion.identity);

        weapon.id = ObjectsHolder.ins.GenerateID();

        weapon.level = 0;

        weapon.type = holdingWeaponType;

        weapon.gridPosition = GridScript.ins.WorldPosToNearestGridPos(createdWeapon.transform.position);

        switch (holdingWeaponType)
        {
        case ObjectType.turret:

            weapon.health = 3;

            ObjectType oneAboveTurret = GridScript.ins.GetSlotObjectType(new Vector2(weapon.gridPosition.x, weapon.gridPosition.y + 1));

            if (oneAboveTurret == ObjectType.NULL || oneAboveTurret == ObjectType.platform || oneAboveTurret == ObjectType.freezebox || oneAboveTurret == ObjectType.flamebox || oneAboveTurret == ObjectType.shooterbox)
            {
                weapon.onCeiling = true;
            }

            MoneyScript.ins.Money -= weaponCostDict[ObjectType.turret];

            break;

        case ObjectType.freezebox:
            MoneyScript.ins.Money -= weaponCostDict[ObjectType.freezebox];
            break;

        case ObjectType.flamebox:
            MoneyScript.ins.Money -= weaponCostDict[ObjectType.flamebox];
            break;

        case ObjectType.shooterbox:
            MoneyScript.ins.Money -= weaponCostDict[ObjectType.shooterbox];
            break;

        case ObjectType.wall:
            weapon.health = 10;
            GridScript.ins.SetSlotObjectType(new Vector2(weapon.gridPosition.x, weapon.gridPosition.y + 1), weapon.type);
            MoneyScript.ins.Money -= weaponCostDict[ObjectType.wall];
            break;
        }

        createdWeapon.GetComponent <WeaponBase>().SetWeaponStats(weapon);

        GridScript.ins.SetSlotObjectType(weapon.gridPosition, weapon.type);

        ObjectsHolder.ins.AddToActiveObjects(weapon);
    }
Ejemplo n.º 4
0
    public override void SetWeaponStats(WeaponEntry wallData)
    {
        id = wallData.id;

        Level = wallData.level;

        health = wallData.health;

        crackingSpriteRenderer.sprite = crackingSprites[9 - (Mathf.RoundToInt((health / maxHealth) * 10) - 1)];
    }
Ejemplo n.º 5
0
    public override void SetWeaponStats(WeaponEntry turretData)
    {
        id = turretData.id;

        Level = turretData.level;

        health = turretData.health;

        if (turretData.onCeiling)
        {
            gameObject.GetComponent <SpriteRenderer>().flipY = true;
            gameObject.GetComponent <SpriteShadow>().flipShadow(true);
        }
    }
Ejemplo n.º 6
0
            public override List <string> GetDifferences(Chunk xiChunk)
            {
                WeaponEntry lOther = xiChunk as WeaponEntry;

                if (!mPosition.Equals(lOther.mPosition) ||
                    WeaponType != lOther.WeaponType ||
                    ShortUnknown != lOther.ShortUnknown)
                {
                    List <string> lRet = base.GetDifferences(xiChunk);
                    lRet.Add(string.Format("Changed weapon of type {0}", WeaponType));
                    return(lRet);
                }

                return(base.GetDifferences(xiChunk));
            }
Ejemplo n.º 7
0
    private void LoadWeapon(WeaponEntry weapon)
    {
        weaponPosition = GridScript.ins.GridPosToWorldPos(weapon.gridPosition);

        if (weapon.type == ObjectType.turret || weapon.type == ObjectType.shooterbox) // If weapon has to be above bullets, put it in front of everything
        {
            weaponPosition = new Vector3(weaponPosition.x, weaponPosition.y, -6);
        }
        else
        {
            weaponPosition = new Vector3(weaponPosition.x, weaponPosition.y, -4); // If the bullet has to be above it, put it behind -5 (the bullet layer)
        }

        switch (weapon.type)
        {
        case ObjectType.turret:
            loadedWeapon = Instantiate(weaponsArray[0], weaponPosition, Quaternion.identity);
            break;

        case ObjectType.freezebox:
            loadedWeapon = Instantiate(weaponsArray[1], weaponPosition, Quaternion.identity);
            break;

        case ObjectType.flamebox:
            loadedWeapon = Instantiate(weaponsArray[2], weaponPosition, Quaternion.identity);
            break;

        case ObjectType.shooterbox:
            loadedWeapon = Instantiate(weaponsArray[3], weaponPosition, Quaternion.identity);
            break;

        case ObjectType.wall:
            loadedWeapon = Instantiate(weaponsArray[4], weaponPosition, Quaternion.identity);
            break;

        default:
            Debug.Log("Defaulted on Weapon Load");
            return;
        }

        loadedWeapon.GetComponent <WeaponBase>().SetWeaponStats(weapon);

        ObjectsHolder.ins.AddToActiveObjects(weapon);

        GridScript.ins.SetSlotObjectType(weapon.gridPosition, weapon.type);
    }
Ejemplo n.º 8
0
 //ADD TO ACTIVE OBJECTS
 public void AddToActiveObjects(WeaponEntry weapon)
 {
     weapons.Add(weapon);
 }
Ejemplo n.º 9
0
    public override void SetWeaponStats(WeaponEntry flameBoxData)
    {
        id = flameBoxData.id;

        Level = flameBoxData.level;
    }
Ejemplo n.º 10
0
 public abstract void SetWeaponStats(WeaponEntry weapon);
Ejemplo n.º 11
0
    public override void SetWeaponStats(WeaponEntry shooterBoxData)
    {
        id = shooterBoxData.id;

        Level = shooterBoxData.level;
    }
Ejemplo n.º 12
0
        public void Deserialise(BinaryReader bin)
        {
            //header
              DeclaredIdx = bin.ReadInt16();
              DeclaredName = StreamUtils.ReadASCIINullTermString(bin.BaseStream);
              if (DeclaredName.Length != 8)
            throw new DeserialisationException("Expecting name to be length 8 & null-terminated", bin.BaseStream.Position);

              //more header:
              OriginPosition = Short3Coord.ReadShort3Coord64(bin);
              RotationVector = Short3Coord.ReadShort3Coord64(bin);
              Width = bin.ReadInt16();
              Height = bin.ReadInt16();
              ScaleX = bin.ReadInt16();
              ScaleY = bin.ReadInt16();

              //every flat has a tex array:
              TextureIds = new short[Width][]; //not allowed 2d initalisers!!!
              TerrainHeight = new short[Width][];
              for (int x = 0; x < Width; x++)
              {
            TextureIds[x] = new short[Height];
            TerrainHeight[x] = new short[Height];
            for (int y = 0; y < Height; y++)
            {
              TextureIds[x][y] = bin.ReadInt16();
              TerrainHeight[x][y] = bin.ReadInt16();
            }
              }

              //General flags
              HasMetaData = StreamUtils.ReadShortFlag(bin);
              FlgB = StreamUtils.ReadShortFlag(bin);
              FlgC = StreamUtils.ReadShortFlag(bin);
              Visible = StreamUtils.ReadShortFlag(bin);
              FlgE = StreamUtils.ReadByteFlag(bin);  //qq that looks wrong to me, but it works!

              //what do these mean?
              NextN = bin.ReadBytes(HasMetaData ? 2 : 6);

              //unless (HasMetaData), we're done...
              if (HasMetaData)
              {
            //load the tex metadata
            TexMetaData = new Byte[Width][][];
            for (int x = 0; x < Width; x++)
            {
              TexMetaData[x] = new Byte[Height][];
              for (int y = 0; y < Height; y++)
              {
            TexMetaData[x][y] = bin.ReadBytes(8);
              }
            }

            //objects:
            short objectCount = bin.ReadInt16();
            Objects = new ObjectEntry[objectCount];
            for (int i = 0; i < objectCount; i++)
            {
              Objects[i] = new ObjectEntry(bin);
            }

            //weapons:
            short weapCount = bin.ReadInt16();
            Weapons = new WeaponEntry[weapCount];
            for (int i = 0; i < weapCount; i++)
            {
              Weapons[i] = new WeaponEntry(bin);
            }
              }
              else if (Utils.ArrayCompare(NextN, new byte[] { 156, 255, 1, 0, 4, 0 }))
              {
            //applying POOL5 hack!! qqq
            Console.Error.WriteLine("Warning: applying POOL5 specific hack to trailing bytes of jumprmp3 Flat");
            TrailingData = bin.ReadBytes(22);
              }
              else if (Utils.ArrayCompare(NextN, new byte[] { 106, 255, 1, 0, 243, 255 }))
              {
            //applying GARDEN3 hack!! qqq
            Console.Error.WriteLine("Warning: applying GARDEN3 specific hack to trailing bytes of grasssht Flat");
            TrailingData = bin.ReadBytes(22);
              }
        }
Ejemplo n.º 13
0
 //武器切り替え実行関数
 public void ChangeState(WeaponEntry nextState)
 {
     currentWeapon.Exit();
     currentWeapon = nextState;
     currentWeapon.Enter();
 }
Ejemplo n.º 14
0
    private bool preSwitch;            //前フレームに武器を切り替えたか

    //初期化関数
    protected override void SubInitialize(GameObject usingObj)
    {
        currentWeapon = hodainGrubState;
        currentWeapon.Enter();
        preSwitch = false;
    }
Ejemplo n.º 15
0
        public void Deserialise(BinaryReader bin)
        {
            //header
            DeclaredIdx  = bin.ReadInt16();
            DeclaredName = StreamUtils.ReadASCIINullTermString(bin.BaseStream);
            if (DeclaredName.Length != 8)
            {
                throw new DeserialisationException("Expecting name to be length 8 & null-terminated", bin.BaseStream.Position);
            }

            //more header:
            OriginPosition = Short3Coord.ReadShort3Coord64(bin);
            RotationVector = Short3Coord.ReadShort3Coord64(bin);
            Width          = bin.ReadInt16();
            Height         = bin.ReadInt16();
            ScaleX         = bin.ReadInt16();
            ScaleY         = bin.ReadInt16();

            //every flat has a tex array:
            TextureIds    = new short[Width][]; //not allowed 2d initalisers!!!
            TerrainHeight = new short[Width][];
            for (int x = 0; x < Width; x++)
            {
                TextureIds[x]    = new short[Height];
                TerrainHeight[x] = new short[Height];
                for (int y = 0; y < Height; y++)
                {
                    TextureIds[x][y]    = bin.ReadInt16();
                    TerrainHeight[x][y] = bin.ReadInt16();
                }
            }

            //General flags
            HasMetaData = StreamUtils.ReadShortFlag(bin);
            FlgB        = StreamUtils.ReadShortFlag(bin);
            FlgC        = StreamUtils.ReadShortFlag(bin);
            Visible     = StreamUtils.ReadShortFlag(bin);
            FlgE        = StreamUtils.ReadByteFlag(bin); //qq that looks wrong to me, but it works!

            //what do these mean?
            NextN = bin.ReadBytes(HasMetaData ? 2 : 6);

            //unless (HasMetaData), we're done...
            if (HasMetaData)
            {
                //load the tex metadata
                TexMetaData = new Byte[Width][][];
                for (int x = 0; x < Width; x++)
                {
                    TexMetaData[x] = new Byte[Height][];
                    for (int y = 0; y < Height; y++)
                    {
                        TexMetaData[x][y] = bin.ReadBytes(8);
                    }
                }

                //objects:
                short objectCount = bin.ReadInt16();
                Objects = new ObjectEntry[objectCount];
                for (int i = 0; i < objectCount; i++)
                {
                    Objects[i] = new ObjectEntry(bin);
                }

                //weapons:
                short weapCount = bin.ReadInt16();
                Weapons = new WeaponEntry[weapCount];
                for (int i = 0; i < weapCount; i++)
                {
                    Weapons[i] = new WeaponEntry(bin);
                }
            }
            else if (Utils.ArrayCompare(NextN, new byte[] { 156, 255, 1, 0, 4, 0 }))
            {
                //applying POOL5 hack!! qqq
                Console.Error.WriteLine("Warning: applying POOL5 specific hack to trailing bytes of jumprmp3 Flat");
                TrailingData = bin.ReadBytes(22);
            }
            else if (Utils.ArrayCompare(NextN, new byte[] { 106, 255, 1, 0, 243, 255 }))
            {
                //applying GARDEN3 hack!! qqq
                Console.Error.WriteLine("Warning: applying GARDEN3 specific hack to trailing bytes of grasssht Flat");
                TrailingData = bin.ReadBytes(22);
            }
        }