示例#1
0
        public static GameObject Create(PrefabName name, Vector3 pos)
        {
            var        pool = NameToObjectPool[name];
            GameObject temp = null;

            for (int i = 0; i < pool.Count; i++)
            {
                if (!pool[i].activeInHierarchy)
                {
                    pool[i].SetActive(true);
                    pool[i].transform.localPosition = pos;
                    temp = pool[i];
                    break;
                }
            }

            if (temp == null)
            {
                temp      = Object.Instantiate(Prefabs[name]);
                temp.name = name.ToString();
                pool.Add(temp);
            }

            return(temp);
        }
示例#2
0
    GameObject GameObjectFactory(PrefabName name)
    {
        switch (name)
        {
        case PrefabName.BULLET:
            return(Instantiate(Prefabs[0]));

        case PrefabName.SPECIAL:
            return(Instantiate(Prefabs[1]));

        case PrefabName.RAYLINE:
            return(Instantiate(Prefabs[2]));

        case PrefabName.BODY_EXPLODE:
            return(Instantiate(Prefabs[3]));

        case PrefabName.AIM_POINT_0:
            return(Instantiate(Prefabs[4]));

        case PrefabName.ENEMY:
            return(Instantiate(Prefabs[5]));

        case PrefabName.SPEED_SHADOW:
            return(Instantiate(Prefabs[6]));
        }
        return(null);
    }
示例#3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (WinName.Length != 0)
            {
                hash ^= WinName.GetHashCode();
            }
            if (PrefabName.Length != 0)
            {
                hash ^= PrefabName.GetHashCode();
            }
            if (CameraName.Length != 0)
            {
                hash ^= CameraName.GetHashCode();
            }
            if (IsRecord != false)
            {
                hash ^= IsRecord.GetHashCode();
            }
            if (IsHover != false)
            {
                hash ^= IsHover.GetHashCode();
            }
            if (CloseDelete != false)
            {
                hash ^= CloseDelete.GetHashCode();
            }
            if (OpenEffect != false)
            {
                hash ^= OpenEffect.GetHashCode();
            }
            return(hash);
        }
示例#4
0
 public ObstacleTemplate(PrefabName prefabName,
                         float startAngle,
                         BehaviourType behaviourType,
                         Vector3 direction)
 {
     PrefabName    = prefabName;
     StartAngle    = startAngle;
     BehaviourType = behaviourType;
     Direction     = direction;
 }
示例#5
0
        public static GameObject CreateInstance(PrefabName prefabName)
        {
            String path = _prefabTypeToPrefabMapping[prefabName];

            GameObject gameObject = (GameObject)GameObject.Instantiate(Resources.Load(path));

            gameObject.name = prefabName.ToString();

            return(gameObject);
        }
示例#6
0
    /*
     * private void OnAimDeadEvent(AgeCalculator obj)
     * {
     *  obj.OnDeadEvent -= OnAimDeadEvent;
     *  GameObject aimSender = obj.gameObject;
     *  int groupId = aimSender.GetComponent<AimController>().GroupId;
     *  List<AimController> nowAims = GetAimById(groupId);
     *  if (nowAims != null)
     *  {
     *      nowAims.Remove(aimSender.GetComponent<AimController>());
     *      Destroy(aimSender);
     *
     *      if (nowAims.Count == 0)
     *      {
     *          if (Aims.ContainsKey(groupId))
     *          {
     *              Aims.Remove(groupId);
     *          }
     *      }
     *  }
     *  CheckIsStopAim();
     * }
     *
     * public void DragAimsByIds(int[] ids, Vector3 pos)
     * {
     *  foreach( int id in ids)
     *  {
     *      List<AimController> nowAims = GetAimById(id);
     *      if (nowAims != null)
     *      {
     *          foreach (AimController a in nowAims)
     *          {
     *              if (a.Dragable)
     *              {
     *                  a.GetComponent<AimController>().SetPosition(pos);
     *                  BodyRotateByAimDir(Player, pos);
     *              }
     *          }
     *      }
     *  }
     * }
     *
     * public List<AimController> GetAimById(int id)
     * {
     *  if(Aims.ContainsKey(id))
     *  {
     *      return Aims[id];
     *  }
     *  return null;
     * }
     *
     * public void ClearAimsByIds( int[] ids )
     * {
     *  foreach( int id in ids)
     *  {
     *      List<AimController> nowAims = GetAimById(id);
     *      if (nowAims != null)
     *      {
     *          foreach (AimController a in nowAims)
     *          {
     *              a.GetComponent<AgeCalculator>().OnDeadEvent -= OnAimDeadEvent;
     *              Destroy(a.gameObject);
     *          }
     *          nowAims.Clear();
     *          if (Aims.ContainsKey(id)) Aims.Remove(id);
     *      }
     *  }
     *  CheckIsStopAim();
     * }
     *
     * void CheckIsStopAim()
     * {
     *
     *  List<PlayerController> buffer = new List<PlayerController>(playersAimCount.Keys);
     *  foreach (PlayerController key in buffer)
     *  {
     *      playersAimCount[key] = false;
     *  }
     *
     *  foreach ( List<AimController> acs in Aims.Values )
     *  {
     *      foreach( AimController ac in acs)
     *      {
     *          playersAimCount[ac.owner] = true;
     *      }
     *  }
     *
     *  foreach( PlayerController owner in playersAimCount.Keys)
     *  {
     *      if( !playersAimCount[owner] )
     *      {
     *          owner.IsAim = false;
     *          owner.UpdateBody();
     *      }
     *  }
     *
     * }
     */
    private void CreateOneBullet(PrefabName bulletName, Vector3 from, Vector3 dir, float force)
    {
        GameObject bullet = GameObjectFactory(bulletName);

        bullet.SetActive(true);
        bullet.transform.parent = ObjectContainer.transform;
        bullet.GetComponent <RectTransform>().position = from;
        bullet.GetComponent <Rigidbody2D>().AddForce(dir * force);
        bullet.GetComponent <AgeCalculator>().OnDeadEvent += OnBulletDeadEvent;
        Bullets.Add(bullet);
    }
示例#7
0
 public GameObject GetGameObject(PrefabName name)
 {
     return(Resources.Load <GameObject>("AllPrefabs/" + name));
 }