Ejemplo n.º 1
0
    public override void Fire()
    {
        if (CanFire())
        {
            float laserDistance = range;

            Ray ray = new Ray(this.transform.position, this.transform.forward);
            RaycastHit[] hits = Physics.RaycastAll(ray, range, 1 << LayerMask.NameToLayer("PhysicalObject"));

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != this.transform.parent.gameObject)
                {
                    laserDistance = Vector3.Distance(hit.collider.transform.position, this.transform.position);

                    DamageData damageData = new DamageData();

                    if (hit.collider.gameObject.tag == "Ship")
                    {
                        damageData.SetData(damage, DamageData.HitLocations.hull);
                    }
                    else if (hit.collider.gameObject.tag == "Shield")
                    {
                        damageData.SetData(damage, DamageData.HitLocations.shield);
                    }

                    hit.collider.gameObject.SendMessageUpwards("ProjectileHit", damageData, SendMessageOptions.DontRequireReceiver);
                    break;
                }
            }

            GameObject projectileObject = (GameObject)Instantiate(projectilePrefab,  this.transform.position, Quaternion.identity);
            Laser laser = projectileObject.GetComponent<Laser>();
            laser.SetLaser(this.transform.position, this.transform.position + (this.transform.forward * laserDistance));

            base.Fire ();
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 將Json資料寫入字典裡
 /// </summary>
 static void LoadJsonDataToDic()
 {
     //文字字典
     String_AttributeDic = new Dictionary <string, String_AttributeData>();
     String_AttributeData.SetData(String_AttributeDic);
     //Sprite字典
     SpriteDic = new Dictionary <string, SpriteData>();
     SpriteData.SetData(SpriteDic);
     //被動施法
     PSpellDic = new Dictionary <int, PassiveSpellData>();
     PassiveSpellData.SetData(PSpellDic);
     //主動施法
     ASpellDic = new Dictionary <int, ActivitySpellData>();
     ActivitySpellData.SetData(ASpellDic);
     DamageDic = new Dictionary <int, DamageData>();
     DamageData.SetData(DamageDic);
     CureDic = new Dictionary <int, CureData>();
     CureData.SetData(CureDic);
     BufferDic = new Dictionary <int, BufferData>();
     BufferData.SetData(BufferDic);
     //天賦字典
     TalentDic = new Dictionary <int, TalentData>();
     TalentData.SetData(TalentDic);
     //武器
     WeaponDic = new Dictionary <int, WeaponData>();
     WeaponData.SetData(WeaponDic);
     //防具
     ArmorDic = new Dictionary <int, ArmorData>();
     ArmorData.SetData(ArmorDic);
     //裝備
     ProtectorDic = new Dictionary <int, ProtectorData>();
     ProtectorData.SetData(ProtectorDic);
     //裝備
     DropDic = new Dictionary <int, DropData>();
     DropData.SetData(DropDic);
     //冒險
     AdventureDic = new Dictionary <int, AdventureData>();
     AdventureData.SetData(AdventureDic);
     //出怪事件
     MonsterEventDic = new Dictionary <int, MonsterEventData>();
     MonsterEventData.SetData(MonsterEventDic);
     //調查事件
     InvestigateEventDic = new Dictionary <int, List <InvestigateEventData> >();
     InvestigateEventData.SetData(InvestigateEventDic);
     //意外事件
     AccidentEventDic = new Dictionary <int, List <AccidentEventData> >();
     AccidentEventData.SetData(AccidentEventDic);
     //結果事件
     EventResultDic = new Dictionary <int, EventResultData>();
     EventResultData.SetData(EventResultDic);
     //紮營事件
     CampDic = new Dictionary <int, List <CampEventData> >();
     CampEventData.SetData(CampDic);
     //怪物
     MonsterGroupDic = new Dictionary <int, List <MonsterData> >();
     MonsterDic      = new Dictionary <int, MonsterData>();
     MonsterData.SetData(MonsterGroupDic, MonsterDic);
     //腳色字典
     RoleDic = new Dictionary <int, RoleData>();
     RoleData.SetData(RoleDic);
     //主屬性字典
     MainAttributeDic = new Dictionary <MainAttribute, MainAttributeData>();
     MainAttributeData.SetData(MainAttributeDic);
     //等級字典
     LevelDic = new Dictionary <int, LevelData>();
     LevelData.SetData(LevelDic);
 }