Exemple #1
0
 protected override void Awake()
 {
     base.Awake();
     m_IsReadyForTransmission = false;
     m_IsInDisForTransmission = false;
     m_IE_SuckPool            = null;
     m_CurSuckPool            = null;
     m_Endurance  = 1f;
     m_IE_EndDown = null;
 }
Exemple #2
0
    private IEnumerator IE_SuckPool(WaterPool pool)
    {
        m_CurSuckPool = pool;

        while (true)
        {
            if (m_CurSuckPool)
            {
                m_CurSuckPool.BeSucked(this);
            }
            else
            {
                StopCoroutine(m_IE_SuckPool);
                m_IE_SuckPool = null;
            }

            yield return(null);
        }
    }
Exemple #3
0
    protected override void OnTrigger_Exit(Collider2D col)
    {
        base.OnTrigger_Exit(col);

        WaterPool pool = col.gameObject.GetComponent <WaterPool>();

        if (m_CurTransType == TransmissionType.Thin &&
            m_CurStatus != RoleStatus.Transmission && pool)
        {
            if (pool == m_CurSuckPool)
            {
                if (m_IE_SuckPool != null)
                {
                    StopCoroutine(m_IE_SuckPool);
                    m_IE_SuckPool = null;
                    m_CurSuckPool = null;
                }
            }
        }
    }
Exemple #4
0
    public void Transmission()
    {
        if (m_CurStatus == RoleStatus.Transmission)
        {
            return;
        }

        m_IsReadyForTransmission = false;
        m_IsInDisForTransmission = false;

        // stop suck
        if (m_IE_SuckPool != null)
        {
            StopCoroutine(m_IE_SuckPool);
            m_IE_SuckPool = null;
            m_CurSuckPool = null;
        }

        m_CurStatus = RoleStatus.Transmission;
        m_AniMng.Transmission();

        // set face
        bool otherIsRight = m_OtherHero.GetFootPos().x > this.GetFootPos().x;

        // this.SetFlipX(!otherIsRight);
        this.SetCurVec_Move(otherIsRight ? Vector2.right : Vector2.left);

        // set position
        if (m_CurTransType == TransmissionType.Thin)
        {
            transform.position = new Vector3(
                m_OtherHero.GetFootPos().x +
                m_TransmissionDis * (otherIsRight ? -1f : 1f),
                m_OtherHero.GetFootPos().y,
                0
                );
        }
    }
        private void Read(DataReader r)
        {
            Magic             = r.ReadUInt32(); //'WMAP'
            Version           = r.ReadUInt32(); //100 - version?
            DataLength        = r.ReadUInt32(); //59360 - data length (excluding last flags array!)
            CornerX           = r.ReadSingle(); //-4050.0f  - min XY?
            CornerY           = r.ReadSingle(); //8400.0f   - max XY?
            TileX             = r.ReadSingle(); //50.0f  - tile size X
            TileY             = r.ReadSingle(); //50.0f  - tile size Y
            Width             = r.ReadUInt16(); //183  - image Width
            Height            = r.ReadUInt16(); //249  - image Height
            WatermapIndsCount = r.ReadUInt32(); //10668
            WatermapRefsCount = r.ReadUInt32(); //11796
            RiverVecsCount    = r.ReadUInt16(); //99
            RiverCount        = r.ReadUInt16(); //13
            LakeVecsCount     = r.ReadUInt16(); //28
            LakeCount         = r.ReadUInt16(); //15
            PoolCount         = r.ReadUInt16(); //314
            ColoursOffset     = r.ReadUInt16(); //13316
            Unks1             = r.ReadBytes(8); //2,2,16,48,16,48,32,0      flags..?


            var shortslen = (int)((WatermapIndsCount + WatermapRefsCount) * 2) + (Height * 4); //offset from here to Zeros1
            var padcount  = (16 - (shortslen % 16)) % 16;                                      //12 .. is this right? all are zeroes.
            var strucslen = ((RiverVecsCount + LakeVecsCount) * 16) + ((RiverCount + LakeCount) * 48) + (PoolCount * 32);
            var datalen   = shortslen + padcount + strucslen;                                  //DataLength calculation
            var extoffs   = padcount + strucslen - 60 - 60;                                    //ExtraFlagsOffset calculation


            CompHeaders = new CompHeader[Height];//249 - image height
            for (int i = 0; i < Height; i++)
            {
                CompHeaders[i].Read(r);
            }

            CompWatermapInds = new short[WatermapIndsCount];//10668
            for (int i = 0; i < WatermapIndsCount; i++)
            {
                CompWatermapInds[i] = r.ReadInt16();
            }

            CompWatermapRefs = new WaterItemRef[WatermapRefsCount];//11796
            for (int i = 0; i < WatermapRefsCount; i++)
            {
                CompWatermapRefs[i] = new WaterItemRef(r.ReadUInt16());
            }

            Zeros1 = r.ReadBytes(padcount);          //align to 16 bytes (position:45984)

            RiverVecs = new Vector4[RiverVecsCount]; //99
            for (int i = 0; i < RiverVecsCount; i++)
            {
                RiverVecs[i] = r.ReadVector4();
            }

            Rivers = new WaterFlow[RiverCount];//13
            for (int i = 0; i < RiverCount; i++)
            {
                Rivers[i] = new WaterFlow(WaterItemType.River, r, RiverVecs);
            }

            LakeVecs = new Vector4[LakeVecsCount];//28
            for (int i = 0; i < LakeVecsCount; i++)
            {
                LakeVecs[i] = r.ReadVector4();
            }

            Lakes = new WaterFlow[LakeCount];//15
            for (int i = 0; i < LakeCount; i++)
            {
                Lakes[i] = new WaterFlow(WaterItemType.Lake, r, LakeVecs);
            }

            Pools = new WaterPool[PoolCount];//314
            for (int i = 0; i < PoolCount; i++)
            {
                Pools[i] = new WaterPool(r);
            }

            ColourCount = (uint)(RiverCount + LakeCount + PoolCount); //342
            Colours     = new Color[ColourCount];                     //342
            for (int i = 0; i < 342; i++)
            {
                Colours[i] = Color.FromAbgr(r.ReadUInt32());
            }


            var flagoff = 0; //assign extra colours out of the main array

            for (int i = 0; i < Rivers.Length; i++)
            {
                var river = Rivers[i];
                river.Colour = Colours[flagoff++];
            }
            for (int i = 0; i < Lakes.Length; i++)
            {
                var lake = Lakes[i];
                lake.Colour = Colours[flagoff++];
            }
            for (int i = 0; i < Pools.Length; i++)
            {
                var pool = Pools[i];
                pool.Colour = Colours[flagoff++];
            }



            for (int i = 0; i < CompWatermapRefs.Length; i++) //assign items to CompWatermapRefs
            {
                var ir = CompWatermapRefs[i];
                switch (ir.Type)
                {
                case WaterItemType.River: CompWatermapRefs[i].Item = Rivers[ir.ItemIndex]; break;

                case WaterItemType.Lake: CompWatermapRefs[i].Item = Lakes[ir.ItemIndex]; break;

                case WaterItemType.Pool: CompWatermapRefs[i].Item = Pools[ir.ItemIndex]; break;
                }
            }



            //decompress main data into grid form
            GridWatermapInds = new short[Width * Height];
            GridWatermapRefs = new WaterItemRef[Width * Height][];
            var reflist = new List <WaterItemRef>();

            for (int y = 0; y < Height; y++)
            {
                var ch = CompHeaders[y];
                for (int i = 0; i < ch.Count; i++)
                {
                    var x = ch.Start + i;
                    var n = CompWatermapInds[ch.Offset + i];
                    var o = y * Width + x;

                    reflist.Clear();
                    WaterItemRef[] refarr = null;
                    if (n >= 0)
                    {
                        var h = CompWatermapRefs[n];
                        reflist.Add(h);
                        var cn = n;
                        while (h.EndOfList == false)
                        {
                            cn++;
                            h = CompWatermapRefs[cn];
                            reflist.Add(h);
                        }

                        refarr = reflist.ToArray();
                    }

                    GridWatermapInds[o] = n;
                    GridWatermapRefs[o] = refarr;
                }
            }



            //var pgm = GetPGM();


            var rem = r.Length - r.Position;//60788

            if (rem != 0)
            {
            }



            //var sb = new StringBuilder();
            //for (int y = Height - 1; y >= 0; y--)
            //{
            //    for (int x = 0; x < Width; x++)
            //    {
            //        var v = GridWatermapVals[y * Width + x];
            //        sb.Append(Convert.ToString(v, 16).ToUpperInvariant().PadLeft(4, '0'));
            //        sb.Append(" ");
            //    }
            //    sb.AppendLine();
            //}
            //var hstr = sb.ToString();
        }