Пример #1
0
    void Update()
    {
        var zMove = 0f;
        var xMove = 0f;

        if (Input.GetKey(KeyCode.W))
        {
            zMove = 1;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            zMove = -1;
        }

        if (Input.GetKey(KeyCode.D))
        {
            xMove = 1;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            xMove = -1;
        }

        moveSpeed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ? MoveSpeed.Run : MoveSpeed.Walk;
        characterController.SimpleMove(transform.rotation * new Vector3(xMove, 0, zMove) * CurrentMoveSpeed);
    }
Пример #2
0
    public void Execute(int index)
    {
        float3 newHeading       = headings[index].Value;
        float  orbitalSpeed     = 10;
        float  closestPlaneDist = 100000;

        for (int j = 0; j < sunPositions.Length; j++)
        {
            float3 sunPos     = sunPositions[j].Value;
            float3 difference = math.normalize(sunPos - planetPositions[index].Value);
            float  distance   = math.lengthSquared(difference) + 0.1f;
            if (distance < closestPlaneDist)
            {
                closestPlaneDist = distance;
            }
            float gravity = math.clamp(distance / 100f, 0, 1);
            newHeading += math.lerp(headings[index].Value, difference, gravity);
        }
        orbitalSpeed    = math.sqrt(500 / closestPlaneDist);
        headings[index] = new Heading {
            Value = math.normalize(newHeading)
        };
        speeds[index] = new MoveSpeed {
            speed = orbitalSpeed
        };
    }
Пример #3
0
    public void LoadStatus(SaveData LoadData)
    {
        Name      = new Name(LoadData.Name);
        Lv        = new Lv(LoadData.Lv);
        Hp        = new Hp(LoadData.MaxHp, LoadData.CurrentHp);
        Mp        = new Mp(LoadData.MaxMp, LoadData.CurrentMp);
        Str       = new Str(LoadData.Str);
        Vit       = new Vit(LoadData.Vit);
        Dex       = new Dex(LoadData.Dex);
        Int       = new Int(LoadData.Int);
        Exp       = new Exp(LoadData.NextExp, LoadData.CurrentExp);
        MoveSpeed = new MoveSpeed(3, 1);

        Direction = new Direction(Animator);

        ChargeSkill = new SwordChargeAtack();
        NormalAtack = new SwordNomalAtack();
        Skill       = NormalAtack;
        Charge      = GameObject.transform.Find("tame").GetComponent <Charge>();
        Weapon      = (GameObject)Resources.Load("prefab/Weapon/Sword");
        Equip       = new Equip();

        Equip.Weapon(LoadData.EquipWeapon);
        Equip.Head(LoadData.EquipHead);
        Equip.Body(LoadData.EquipBody);
        Equip.Hand(LoadData.EquipHand);
        Equip.Foot(LoadData.EquipFoot);
        Equip.Accessory(LoadData.EquipAccessory);
    }
Пример #4
0
    public List <string> MakeListToItemInfo()
    {
        List <string> list = new List <string>();

        list.Add(Class);
        list.Add("Price " + Price.ToString());

        if (Hp != 0)
        {
            list.Add("+ HP " + Hp.ToString());
        }
        if (Attack != 0)
        {
            list.Add("+ Attack " + Attack.ToString());
        }
        if (Defense != 0)
        {
            list.Add("+ Defense " + Defense.ToString());
        }
        if (MoveSpeed != 0)
        {
            list.Add("+ Move Speed " + MoveSpeed.ToString());
        }
        if (AttackSpeed != 0)
        {
            list.Add("+ Attack Speed " + AttackSpeed.ToString());
        }

        return(list);
    }
Пример #5
0
 // Called when the owning graph starts playing
 public override void OnGraphStart(Playable playable)
 {
     if (!EntityMgr.HasComponent <MoveSpeed>(SpeedOwner))
     {
         return;
     }
     lastSpeed = EntityMgr.GetComponentData <MoveSpeed>(SpeedOwner);
 }
Пример #6
0
    public override void CopyInfo(SerializedClass info)
    {
        MoveCharacterInfo i = (MoveCharacterInfo)info;

        charToMove           = GameObject.Find(i.CharName).transform;
        destination.position = i.Destination;
        moveSpeed            = i.MoveSpeed;
        customSpeed          = i.CustomSpeed;
    }
Пример #7
0
    void OnChangeTarget(Transform oldTarget)
    {
        if (oldTarget == null)
        {
            StopCoroutine(changeDirectionCoroutine);
            StartCoroutine(ChangeTargetPosition());
        }

        MoveSpeed.ResetValue();
    }
Пример #8
0
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);
    }
Пример #9
0
    public List <string> MakeListToCharacterStat()
    {
        List <string> list = new List <string>();

        list.Add(Hp.ToString());
        list.Add(Attack.ToString());
        list.Add(Defense.ToString());
        list.Add(MoveSpeed.ToString());
        list.Add(AttackSpeed.ToString());

        return(list);
    }
    protected override void OnUpdate()
    {
        for (int i = 0; i < enemies.Length; i++)
        {
            Position  position = enemies.positions[i];
            Rotation  rotation = enemies.rotations[i];
            MoveSpeed speed    = enemies.moveSpeeds[i];
            ShipData  shipData = enemies.shipData[i];

            position.Value = MovementUtil.Move(position.Value, math.forward(rotation.Value), speed.speed, Time.deltaTime, shipData.bottomBound, shipData.topBound);

            enemies.positions[i] = position;
        }
    }
Пример #11
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        dstManager.AddComponentData(entity, new DealsDamage {
            Value = 20
        });
        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        dstManager.AddComponentData(entity, moveSpeed);
        TimeToLive ttl = new TimeToLive {
            Value = lifeTime
        };

        dstManager.AddComponentData(entity, ttl);
    }
Пример #12
0
    //将GameObject转换为实体
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));         //实体添加MoveForeward组件

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);          //给实体Entity添加MoveSpeed组件数据

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive);          //给实体Entity添加TimeToLive组件
    }
Пример #13
0
 public Tech(bool Spawned, bool Selected, Vector3 CurrentCoord, bool IsArrested, bool IsDead, bool IsVisible, int TimesSpawned, Stance stance, MoveSpeed moveSpeed, bool IsinDark, State state, Type type)
 {
     // Use methods to randomly generate these values.
     this.Spawned = Spawned;
     this.Selected = Selected;
     this.CurrentCoord = CurrentCoord;
     this.IsArrested = IsArrested;
     this.IsDead = IsDead;
     this.IsVisible = IsVisible;
     this.TimesSpawned = TimesSpawned;
     this.stance = stance;
     this.moveSpeed = moveSpeed;
     this.IsinDark = IsinDark;
     this.state = state;
     this.type = type;
     //GuardRoute = new List();
 }
Пример #14
0
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));
        //manager.AddComponent(entity, typeof(EnemyTag));

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive);
    }
Пример #15
0
 public Tech(bool Spawned, bool Selected, Vector3 CurrentCoord, bool IsArrested, bool IsDead, bool IsVisible, int TimesSpawned, Stance stance, MoveSpeed moveSpeed, bool IsinDark, State state, Type type)
 {
     // Use methods to randomly generate these values.
     this.Spawned      = Spawned;
     this.Selected     = Selected;
     this.CurrentCoord = CurrentCoord;
     this.IsArrested   = IsArrested;
     this.IsDead       = IsDead;
     this.IsVisible    = IsVisible;
     this.TimesSpawned = TimesSpawned;
     this.stance       = stance;
     this.moveSpeed    = moveSpeed;
     this.IsinDark     = IsinDark;
     this.state        = state;
     this.type         = type;
     //GuardRoute = new List();
 }
    void Update()
    {
        var       input     = new PlayerInput();
        AxisInput axisInput = input.MainAxis();

        MoveSpeed speed         = new MoveSpeed(3f);
        Vector3   cameraForward = cameraTransformCache.forward;

        MoveVector2 moveVector = new MoveVector2(axisInput.value);
        Vector3     vector3    = moveVector
                                 .Multi(speed)
                                 .MultiCurrentFrameTime()
                                 .RotateTo(cameraForward)
                                 .SolveThatSlantIsRoot2()
                                 .ToXZOfVector3();

        charaPresenter.Move(vector3);
    }
Пример #17
0
    private void handlePizzaComplete(int pizzaIndex)
    {
        Entity     pizzaEntity   = pizzaData.Entities[pizzaIndex];
        PizzaGroup pizzaGroup    = pizzaData.PizzaGroup[pizzaIndex];
        Position2D pizzaPosition = pizzaData.Position[pizzaIndex];
        PizzaCost  pizzaCost     = pizzaData.PizzaCost[pizzaIndex];

        // Pizza is done.
        Debug.Log("PIZZA DONE - " + pizzaGroup.PizzaId + ": " + pizzaCost.OrderCost + " | " + pizzaCost.ActualCost);

        // Update global score.
        PostUpdateCommands.CreateEntity();
        PostUpdateCommands.AddComponent(new DeductScore {
            Value = pizzaCost.ActualCost
        });
        PostUpdateCommands.AddSharedComponent(new ScoringGroup {
            GroupId = 0
        });

        // Delete this Pizza.
        MoveSpeed toWindow = new MoveSpeed {
            speed = BootStrap.GameSettings.ArrowSpeed
        };
        TimedLife timedLife = new TimedLife {
            TimeToLive = 10.0f
        };

        PostUpdateCommands.AddComponent(pizzaEntity, toWindow);
        PostUpdateCommands.AddComponent(pizzaEntity, timedLife);
        PostUpdateCommands.RemoveComponent <PizzaGroup>(pizzaEntity);

        // TODO: While ingredients are flying off with the pizza, arrows could hit them.
        for (int i = 0; i < IngredientData.CalculateLength(); i++)
        {
            Entity ingredientEntity = IngredientData.GetEntityArray()[i];
            //PostUpdateCommands.AddComponent(ingredientEntity, toWindow);
            //PostUpdateCommands.AddComponent(ingredientEntity, timedLife);
            //PostUpdateCommands.RemoveComponent<PizzaGroup>(ingredientEntity);
            PostUpdateCommands.DestroyEntity(ingredientEntity);
        }

        // Create new Pizza.
        createNewPizza(pizzaIndex);
    }
    // when boss is converted into entity
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));  // move vertically
        manager.AddComponent(entity, typeof(BossMoving));   // move horizontally
        manager.AddComponent(entity, typeof(EnemyTag));     // this is enemy
        manager.AddComponent(entity, typeof(BossTag));      // this is boss

        MoveSpeed moveSpeed = new MoveSpeed {
            ValueX = speed, ValueZ = speed
        };

        manager.AddComponentData(entity, moveSpeed);     // set moving speed

        Health health = new Health {
            Value = enemyHealth
        };

        manager.AddComponentData(entity, health);     // set health value
    }
        public static double ToFocus(this MoveSpeed speed)
        {
            switch (speed)
            {
            case MoveSpeed.None: return(0);

            case MoveSpeed.SuperSlow: return(-1);

            case MoveSpeed.Slow: return(-0.5);

            case MoveSpeed.Average: return(0);

            case MoveSpeed.Fast: return(0.5);

            case MoveSpeed.SuperFast: return(1);

            default: throw new ArgumentOutOfRangeException("speed", speed, null);
            }
        }
Пример #20
0
        public void Execute(int index)
        {
            float3 newHeading   = headings[index].Value;
            float  orbitalSpeed = 10;

            float3 sunPos     = new float3(sunPosition.x, sunPosition.y, sunPosition.z);
            float3 difference = math.normalize(sunPos - planetPositions[index].Value);
            float  distance   = math.lengthSquared(difference) + 0.1f; // + 0.1f to be sure it is not zero
            float  gravity    = math.clamp(distance / 100.0f, 0, 1);

            newHeading += math.lerp(headings[index].Value, difference, gravity);

            orbitalSpeed    = math.sqrt(500 / distance);
            headings[index] = new Heading {
                Value = math.normalize(newHeading)
            };
            speeds[index] = new MoveSpeed {
                speed = orbitalSpeed
            };
        }
Пример #21
0
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(EnemyTag));
        manager.AddComponent(entity, typeof(MoveForward));

        RogueUtils.TurnSpeed turn_speed = new RogueUtils.TurnSpeed {
            Value = turnSpeed
        };
        manager.AddComponentData(entity, turn_speed);

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);

        Health health = new Health {
            Value = enemyHealth
        };

        manager.AddComponentData(entity, health);
    }
    // add component when gameObject convert into entity
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));  // move vertically
        manager.AddComponent(entity, typeof(EnemyTag));     // this is enemy

        MoveSpeed moveSpeed = new MoveSpeed {
            ValueX = speed, ValueZ = speed
        };

        manager.AddComponentData(entity, moveSpeed);     // set moving speed

        Health health = new Health {
            Value = enemyHealth
        };

        manager.AddComponentData(entity, health);     // set health value

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive);         // set automatic destroy time count
    }
Пример #23
0
    //Enemy Collision
    // void OnTriggerEnter(Collider theCollider)
    // {
    //     if (!theCollider.CompareTag("Bullet"))
    //         return;
    //
    //     enemyHealth--;
    //     shootTextProController.CreatShootText("-1", this.transform);
    //     if (enemyHealth <= 0)
    //     {
    //         Destroy(gameObject);
    //         BulletImpactPool.PlayBulletImpact(transform.position);
    //     }
    // }

    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(EnemyTag));
        manager.AddComponent(entity, typeof(MoveForward));

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);

        Health health = new Health {
            Value = enemyHealth, beHitValue = 0f
        };

        manager.AddComponentData(entity, health);

        Damage damage = new Damage {
            value = 1f
        };

        manager.AddComponentData(entity, damage);
    }
Пример #24
0
    protected override void OnUpdate()
    {
        float deltaTime = Time.deltaTime;
        float totalTime = Time.timeSinceLevelLoad;

        for (int i = 0; i < components.Length; i++)
        {
            Position            position      = components.positions[i];
            MoveSpeed           movementSpeed = components.moveSpeeds[i];
            CircleBounceECSData bounce        = components.bounce[i];

            float  sinTime = math.sin(totalTime + bounce.bounceOffset);
            float  movementSpeedAdjusted = movementSpeed.speed * deltaTime;
            float3 prevPosition          = position.Value;

            prevPosition.x += sinTime * movementSpeedAdjusted;
            prevPosition.z += Mathf.Cos(totalTime + bounce.bounceOffset) * movementSpeedAdjusted;
            prevPosition.y  = math.abs(sinTime) * bounce.height * bounce.speed;

            position.Value          = prevPosition;
            components.positions[i] = position;
        }
    }
    // add component when gameObject convert into entity
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));     // move vertically
        manager.AddComponent(entity, typeof(PlayerBulletTag)); // it is a player bullet
        manager.AddComponent(entity, typeof(BulletTag));       // it is a bullet

        MoveSpeed moveSpeed = new MoveSpeed {
            ValueX = speed, ValueZ = speed
        };

        manager.AddComponentData(entity, moveSpeed); // add bullet move speed

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive); // add automatic destroy time count

        Health bulletHealth = new Health {
            Value = health
        };

        manager.AddComponentData(entity, bulletHealth); // add bullet health
    }
    // add component when gameObject convert into entity
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(EnemyBulletTag)); // this is a enemy bullet
        manager.AddComponent(entity, typeof(MoveForward));    // move forward tag (move vertically)
        manager.AddComponent(entity, typeof(BulletTag));      // bullet tag (it is a bullet)

        MoveSpeed moveSpeed = new MoveSpeed {
            ValueX = speed, ValueZ = speed
        };

        manager.AddComponentData(entity, moveSpeed); // move speed tag (set bullet move speed)

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive); // time to live tag (set bullet automatic destroy count)

        Health bulletHealth = new Health {
            Value = health
        };

        manager.AddComponentData(entity, bulletHealth); // set bullet health
    }
Пример #27
0
    public void NewGame(string name)
    {
        Name      = new Name(name);
        Lv        = new Lv(1);
        Hp        = new Hp(50, 50);
        Mp        = new Mp(10, 10);
        Str       = new Str(1);
        Vit       = new Vit(1);
        Dex       = new Dex(1);
        Int       = new Int(1);
        Exp       = new Exp(100, 0);
        MoveSpeed = new MoveSpeed(3, 1);

        Equip = new Equip();

        Direction = new Direction(Animator);

        Weapon = (GameObject)Resources.Load("prefab/Weapon/Sword");

        ChargeSkill = new SwordChargeAtack();
        NormalAtack = new SwordNomalAtack();
        Skill       = NormalAtack;
        Charge      = GameObject.transform.Find("tame").GetComponent <Charge>();
    }
Пример #28
0
 public void RemoveModifier(IStatsModifier modifier)
 {
     if (AbilityPower.RemoveStatModificator(modifier.AbilityPower))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Base_Ap, AbilityPower.BaseValue);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ap_Flat, AbilityPower.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ap_Pct, AbilityPower.PercentBonus);
     }
     if (Armor.RemoveStatModificator(modifier.Armor))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor, Armor.Total);
     }
     if (ArmorPenetration.RemoveStatModificator(modifier.ArmorPenetration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor_Pen_Flat, ArmorPenetration.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor_Pen_Pct, ArmorPenetration.PercentBonus);
     }
     if (AttackDamage.RemoveStatModificator(modifier.AttackDamage))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Base_Ad, AttackDamage.BaseValue);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ad_Flat, AttackDamage.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ad_Pct, AttackDamage.PercentBonus);
     }
     if (AttackSpeedMultiplier.RemoveStatModificator(modifier.AttackSpeed))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Atks_multiplier, AttackSpeedMultiplier.Total);
     }
     if (CriticalChance.RemoveStatModificator(modifier.CriticalChance))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Crit_Chance, CriticalChance.Total);
     }
     GoldPerSecond.RemoveStatModificator(modifier.GoldPerSecond);
     if (HealthPoints.RemoveStatModificator(modifier.HealthPoints))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_MaxHp, HealthPoints.Total);
     }
     if (HealthRegeneration.RemoveStatModificator(modifier.HealthRegeneration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Hp5, HealthRegeneration.Total);
     }
     if (LifeSteal.RemoveStatModificator(modifier.LifeSteel))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_LifeSteal, LifeSteal.Total);
     }
     if (MagicResist.RemoveStatModificator(modifier.MagicResist))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Armor, MagicResist.Total);
     }
     if (MagicPenetration.RemoveStatModificator(modifier.MagicPenetration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Pen_Flat, MagicPenetration.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Pen_Pct, MagicPenetration.PercentBonus);
     }
     if (ManaPoints.RemoveStatModificator(modifier.ManaPoints))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_MaxMp, ManaPoints.Total);
     }
     if (ManaRegeneration.RemoveStatModificator(modifier.ManaRegeneration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Mp5, ManaRegeneration.Total);
     }
     if (MoveSpeed.RemoveStatModificator(modifier.MoveSpeed))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_Speed, MoveSpeed.Total);
     }
     if (Range.RemoveStatModificator(modifier.Range))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Range, Range.Total);
     }
     if (Size.RemoveStatModificator(modifier.Size))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_ModelSize, Size.Total);
     }
     if (SpellVamp.RemoveStatModificator(modifier.SpellVamp))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_SpellVamp, SpellVamp.Total);
     }
     if (Tenacity.RemoveStatModificator(modifier.Tenacity))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Tenacity, Tenacity.Total);
     }
 }
Пример #29
0
 public CharacterAttackAndMovement(Character character)
 {
     CharacterId = character.Id;
     AttackSpeed = character.AttackSpeed;
     MoveSpeed   = character.MoveSpeed;
 }
Пример #30
0
        private void ReadMapEventOnePage(ICollection <MapEventPage> mapEventPages)
        {
            var result = new MapEventPage();

            // ヘッダチェック
            foreach (var b in MapEventPage.Header)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"マップイベントページのヘッダが異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            var graphicInfo = new MapEventPageGraphicInfo();

            // タイル画像ID
            var graphicTileId = (MapEventTileId)ReadStatus.ReadInt();

            if (graphicTileId != MapEventTileId.NotUse)
            {
                graphicInfo.IsGraphicTileChip = true;
                graphicInfo.GraphicTileId     = graphicTileId;
            }

            ReadStatus.IncreaseIntOffset();

            // キャラチップ名
            var charaChipString = ReadStatus.ReadString();

            if (!graphicInfo.IsGraphicTileChip)
            {
                graphicInfo.CharaChipFilePath = charaChipString.String;
            }

            ReadStatus.AddOffset(charaChipString.ByteLength);

            // 初期キャラ向き
            var initDirection = ReadStatus.ReadByte();

            graphicInfo.InitDirection = CharaChipDirection.FromByte(initDirection);
            ReadStatus.IncreaseByteOffset();

            // 初期アニメーション番号
            graphicInfo.InitAnimationId = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // キャラチップ透過度
            graphicInfo.CharaChipOpacity = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // キャラチップ表示形式
            graphicInfo.CharaChipDrawType = PictureDrawType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            result.GraphicInfo = graphicInfo;

            var bootInfo = new MapEventPageBootInfo();

            // 起動条件
            bootInfo.MapEventBootType = MapEventBootType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 条件1~4演算子 & 使用フラグ
            var conditions = new List <MapEventBootCondition>
            {
                new MapEventBootCondition(),
                new MapEventBootCondition(),
                new MapEventBootCondition(),
                new MapEventBootCondition(),
            };

            for (var i = 0; i < 4; i++)
            {
                conditions[i].Operation    = CriteriaOperator.FromByte((byte)(ReadStatus.ReadByte() & 0xF0));
                conditions[i].UseCondition = (byte)(ReadStatus.ReadByte() & 0x0F) != 0;
                ReadStatus.IncreaseByteOffset();
            }

            // 条件1~4左辺
            for (var i = 0; i < 4; i++)
            {
                conditions[i].LeftSide = ReadStatus.ReadInt();
                ReadStatus.IncreaseIntOffset();
            }

            // 条件1~4右辺
            for (var i = 0; i < 4; i++)
            {
                conditions[i].RightSide = ReadStatus.ReadInt();
                ReadStatus.IncreaseIntOffset();
                bootInfo.SetEventBootCondition(i, conditions[i]);
            }

            result.BootInfo = bootInfo;

            var moveRouteInfo = new MapEventPageMoveRouteInfo();

            // アニメ速度
            moveRouteInfo.AnimateSpeed = AnimateSpeed.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動速度
            moveRouteInfo.MoveSpeed = MoveSpeed.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動頻度
            moveRouteInfo.MoveFrequency = MoveFrequency.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動ルート
            moveRouteInfo.MoveType = MoveType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            var option = new MapEventPageOption();

            // オプション
            var optionByte = ReadStatus.ReadByte();

            option.SetOptionFlag(optionByte);
            ReadStatus.IncreaseByteOffset();

            result.Option = option;

            // カスタム移動ルートフラグ
            var actionEntry         = new ActionEntry();
            var customMoveRouteFlag = ReadStatus.ReadByte();

            actionEntry.SetOptionFlag(customMoveRouteFlag);
            ReadStatus.IncreaseByteOffset();

            // 動作指定コマンド数
            actionEntry.CommandList = ReadCharaMoveCommand();

            moveRouteInfo.CustomMoveRoute = actionEntry;
            result.MoveRouteInfo          = moveRouteInfo;

            // イベント行数
            var eventLength = ReadStatus.ReadInt();

            ReadStatus.IncreaseIntOffset();

            // イベントコマンド
            var eventCommandListReader = new EventCommandListReader();

            result.EventCommands = eventCommandListReader.Read(eventLength, ReadStatus);

            // イベントコマンド終端チェック
            foreach (var b in EventCommandList.EndEventCommand)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"イベントコマンド後の値が異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            // 影グラフィック番号
            result.ShadowGraphicId = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // 接触範囲拡張X
            var rangeWidth = ReadStatus.ReadByte();

            ReadStatus.IncreaseByteOffset();

            // 接触範囲拡張Y
            var rangeHeight = ReadStatus.ReadByte();

            ReadStatus.IncreaseByteOffset();

            result.HitExtendRange = (rangeWidth, rangeHeight);

            // イベントページ末尾チェック
            foreach (var b in MapEventPage.Footer)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"イベントページ末尾の値が異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            // 完了
            mapEventPages.Add(result);
        }
Пример #31
0
        protected override void OnUpdate()
        {
            var uniqueTypes = new List <Spawn>(10); //make ten unique type?

            attachArch = GameManagerGreg.instance.attachArchetype;

            EntityManager.GetAllUniqueSharedComponentData(uniqueTypes);
            //bc shared component data may have non-blittable types and thus need a list not a nativeContainer

            int spawnInstanceCount = 0; //how many spawn instances are there?

            //Debug.Log("on Update");
            //Debug.Log(uniqueTypes.Count);
            for (int sharedIndex = 0; sharedIndex != uniqueTypes.Count; sharedIndex++)
            {
                //Debug.Log(sharedIndex);
                var spawner = uniqueTypes[sharedIndex];
                m_MainGroup.SetFilter(spawner);
                var entities = m_MainGroup.GetEntityArray();
                Debug.Log(entities.Length);

                spawnInstanceCount += entities.Length;
            } //i'm not sure what this does....?
            Debug.Log(spawnInstanceCount);

            if (spawnInstanceCount == 0) //if no spawn instances then stop
            {
                return;
            }

            //instantiate an spawnInstance
            var spawnInstances = new NativeArray <SpawnSystemInstance>(spawnInstanceCount, Allocator.Temp); //native array of components

            {
                int spawnIndex = 0;
                for (int sharedIndex = 0; sharedIndex != uniqueTypes.Count; sharedIndex++) //for each
                {
                    var spawner = uniqueTypes[sharedIndex];
                    m_MainGroup.SetFilter(spawner);
                    var entities  = m_MainGroup.GetEntityArray();
                    var positions = m_MainGroup.GetComponentDataArray <Position>();
                    var depths    = m_MainGroup.GetComponentDataArray <Depth>();
                    //var radii = m_MainGroup.GetComponentDataArray<RingRadius>();


                    for (int entityIndex = 0; entityIndex < entities.Length; entityIndex++)
                    {
                        var spawnInstance = new SpawnSystemInstance();

                        spawnInstance.sourceEntity = entities[entityIndex];
                        spawnInstance.spawnerIndex = sharedIndex;
                        spawnInstance.position     = positions[entityIndex].Value;
                        spawnInstance.depth        = depths[entityIndex].depth;
                        //spawnInstance.radius = radii[entityIndex].Value;

                        spawnInstances[spawnIndex] = spawnInstance;
                        spawnIndex++;
                    }
                }
            }


            //init speed of harmonic ratios
            float[] initSpeedArray = new float[5] {
                1, 2, 4, 8, 16
            };
            for (int q = 0; q < initSpeedArray.Length; q++)
            {
                initSpeedArray[q] = (initSpeedArray[q] * math.pow(2, -1));
            }

            for (int spawnIndex = 0; spawnIndex < spawnInstances.Length; spawnIndex++)
            {
                int    spawnerIndex = spawnInstances[spawnIndex].spawnerIndex;
                var    spawner      = uniqueTypes[spawnerIndex];
                var    entities     = new NativeArray <Entity>(spawner.ringsPerSystem * spawner.objsPerRing, Allocator.Temp);
                var    prefab       = spawner.prefab;
                float  radius       = spawner.radius;
                float3 center       = spawnInstances[spawnIndex].position;
                var    sourceEntity = spawnInstances[spawnIndex].sourceEntity;
                var    sourceDepth  = spawnInstances[spawnIndex].depth;

                EntityManager.Instantiate(prefab, entities);

                //vars for settings rings
                float zRot          = 0;
                float increment     = 180 / spawner.ringsPerSystem;          //increment is 2*pi / numPartitions
                float ringIncrement = Mathf.PI * 2.0f / spawner.objsPerRing; //increment is 2*pi / numPartitions

                //float scaleConstant = 360 / (Mathf.PI * 2.0f);


                if (sourceDepth == 1)
                {
                    for (int q = 0; q < initSpeedArray.Length; q++)
                    {
                        initSpeedArray[q] = initSpeedArray[q] / 2;
                    }
                }


                for (int i = 0; i < spawner.ringsPerSystem; i++)
                {
                    float angle = 0;

                    var ringPositions = new NativeArray <float3>(spawner.objsPerRing, Allocator.Temp);

                    Quaternion rotation = Quaternion.Euler(0f, 0f, zRot);

                    GeneratePoints.GenerateWorldRing(center, radius, rotation, ref ringPositions);

                    float initZRotSpeed = 4 * initSpeedArray[UnityEngine.Random.Range(0, initSpeedArray.Length)];



                    //for each ring do what?
                    //grab a dummy archetype of rotation.
                    //set the source rotation. the parent rotation. so sourceEntity
                    //I dont think that'll work bc its only parented after the update in transformupdatesystem
                    for (int j = 0; j < spawner.objsPerRing; j++)
                    {
                        var position = new Position
                        {
                            Value = ringPositions[j]
                        };
                        EntityManager.SetComponentData(entities[(i * spawner.objsPerRing) + j], position);
                        //set position and add in other variables
                        //var rotationSpeed = new RotationSpeed
                        //{
                        //    Value = UnityEngine.Random.Range(-1f, 1f)
                        //};

                        //Debug.Log(rotationSpeed.Value);

                        //EntityManager.SetComponentData(entities[(i * spawner.objsPerRing) + j], rotationSpeed);

                        //revolve rings

                        //set move speed - TODO cool stuff

                        //how to set move speed
                        float initMoveSpeed = initSpeedArray[UnityEngine.Random.Range(0, initSpeedArray.Length)];


                        //init move speed is one of 5 - need to scale based on depth
                        var moveSpeed = new MoveSpeed
                        {
                            speed = initMoveSpeed
                        };
                        EntityManager.SetComponentData(entities[(i * spawner.objsPerRing) + j], moveSpeed);


                        var scale = new Scale
                        {
                            Value = UnityEngine.Random.Range(.4f, .6f)
                        };
                        EntityManager.SetComponentData(entities[(i * spawner.objsPerRing) + j], scale);


                        var initOffset = new RingRevolve
                        {
                            //center = new float3(0, 0, 0),
                            initOffset        = angle,
                            radius            = spawner.radius,
                            zRotation         = zRot,
                            initSpeed         = initMoveSpeed,
                            initRandSpeed     = UnityEngine.Random.Range(-5f, 5f),
                            initZRotSpeed     = initZRotSpeed,
                            initRandZRotSpeed = UnityEngine.Random.Range(-5f, 5f),
                        };
                        EntityManager.SetComponentData(entities[(i * spawner.objsPerRing) + j], initOffset);
                        angle = angle + ringIncrement;

                        //for parenting
                        var attachEntity = EntityManager.CreateEntity(attachArch);
                        EntityManager.SetComponentData(attachEntity, new Attach
                        {
                            Child  = entities[(i * spawner.objsPerRing) + j],
                            Parent = sourceEntity
                        });
                    }
                    zRot = zRot + increment; //increment z

                    ringPositions.Dispose();

                    //zRot = zRot+increment;
                }

                /*
                 * for (int i = 0; i < count; i++)
                 * {
                 *  var position = new Position
                 *  {
                 *      Value = spawnPositions[i]
                 *  };
                 *
                 *  var attachEntity = EntityManager.CreateEntity(attachArch);
                 *  //EntityManager.AddComponent(SpawnAttach, new Attach());
                 *  EntityManager.SetComponentData(attachEntity, new Attach
                 *  {
                 *      Child = entities[i],
                 *      Parent = sourceEntity
                 *  });
                 *
                 *  EntityManager.SetComponentData(entities[i], position);
                 * }
                 */

                EntityManager.RemoveComponent <Spawn>(sourceEntity);

                //spawnPositions.Dispose();
                entities.Dispose();
            }
            spawnInstances.Dispose();
        }