public void Reinit()
 {
     foreach (KeyValuePair <int, GameObject> item in dicBrickMan)
     {
         LookCoordinator component = item.Value.GetComponent <LookCoordinator>();
         if (null != component)
         {
             component.ChangeWeapon(RoomManager.Instance.DefaultWeaponType);
         }
     }
 }
Пример #2
0
 public void Start()
 {
     rotator = mySelf.GetComponent <AutoRotator>();
     cordi   = mySelf.GetComponent <LookCoordinator>();
     cordi.Init(mirror: true);
     cordi.TestGender = true;
     string[] usings = MyInfoManager.Instance.GetUsings();
     for (int i = 0; i < usings.Length; i++)
     {
         cordi.Equip(usings[i]);
     }
     cordi.TestGender    = false;
     Weapon.isInitialize = true;
     cordi.ChangeWeapon(Weapon.TYPE.MAIN);
     Weapon.isInitialize = false;
     flip      = false;
     deltaTime = 0f;
 }
    public GameObject AddBrickMan(BrickManDesc desc)
    {
        Vector3 position = new Vector3(0f, 11000f, 0f);

        if (freeInvisiblePositionQ.Count <= 0)
        {
            Debug.LogError("No more free Invisible Position ");
        }
        else
        {
            position = freeInvisiblePositionQ.Dequeue();
        }
        GameObject gameObject = Object.Instantiate((Object)brickMan, position, Quaternion.Euler(0f, 0f, 0f)) as GameObject;

        if (null == gameObject)
        {
            Debug.LogError("Fail to instantiate a brick man ");
            return(null);
        }
        PlayerProperty component = gameObject.GetComponent <PlayerProperty>();

        if (null == component)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError("New brickman doesnt have PlayerProperty ");
            return(null);
        }
        component.Desc = desc;
        component.InvisiblePosition = position;
        TPController component2 = gameObject.GetComponent <TPController>();

        if (null == component2)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError("New brickman doesnt have ThirdPersonController");
            return(null);
        }
        Camera camera = null;

        Camera[] componentsInChildren = gameObject.GetComponentsInChildren <Camera>();
        if (componentsInChildren != null)
        {
            string value = "Near";
            if (Application.loadedLevelName == "Result4Defense")
            {
                value = "Far";
            }
            int num = 0;
            while (camera == null && num < componentsInChildren.Length)
            {
                if (componentsInChildren[num].name.Contains(value))
                {
                    camera = componentsInChildren[num];
                }
                num++;
            }
        }
        if (null == camera)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError(" New brickman doesnt have Overlay camera ");
            return(null);
        }
        if (freeOverlayQ.Count <= 0)
        {
            Debug.LogError("No more freeOverlay ");
        }
        camera.enabled       = true;
        camera.targetTexture = freeOverlayQ.Dequeue();
        Weapon.isInitialize  = true;
        LookCoordinator component3 = gameObject.GetComponent <LookCoordinator>();

        if (null == component3)
        {
            Object.DestroyImmediate(gameObject);
            Debug.LogError("New brickman doesnt have LookCoordinator");
            return(null);
        }
        component3.Init(mirror: false);
        for (int i = 0; i < desc.Equipment.Length; i++)
        {
            TItem tItem = TItemManager.Instance.Get <TItem>(desc.Equipment[i]);
            if (tItem != null)
            {
                string itemCode = desc.Equipment[i];
                if (tItem.type == TItem.TYPE.WEAPON)
                {
                    TWeapon tWeapon = (TWeapon)tItem;
                    int     num2    = 0;
                    while (desc.WpnChg != null && num2 < desc.WpnChg.Length)
                    {
                        TItem tItem2 = TItemManager.Instance.Get <TItem>(desc.WpnChg[num2]);
                        if (tItem2 != null && tItem2.type == TItem.TYPE.WEAPON)
                        {
                            TWeapon tWeapon2 = (TWeapon)tItem2;
                            if (tWeapon.slot == tWeapon2.slot)
                            {
                                itemCode = desc.WpnChg[num2];
                            }
                        }
                        num2++;
                    }
                    int num3 = 0;
                    while (desc.DrpItm != null && num3 < desc.DrpItm.Length)
                    {
                        TItem tItem3 = TItemManager.Instance.Get <TItem>(desc.DrpItm[num3]);
                        if (tItem3 != null && tItem3.type == TItem.TYPE.WEAPON)
                        {
                            TWeapon tWeapon3 = (TWeapon)tItem3;
                            if (tWeapon.slot == tWeapon3.slot)
                            {
                                itemCode = desc.DrpItm[num3];
                            }
                        }
                        num3++;
                    }
                }
                component3.Equip(itemCode);
            }
        }
        component3.ChangeWeapon(RoomManager.Instance.DefaultWeaponType);
        dicBrickMan.Add(desc.Seq, gameObject);
        Weapon.isInitialize = false;
        return(gameObject);
    }