示例#1
0
    public virtual void SomethingPutAbove()
    {
        foreach (Transform obj in transform.Find("Inventory"))
        {
            obj.GetComponent <ObjectOnBloc>().SomethingPutAbove();
        }
        if (isSpawnPoint)
        {
            Placeable above = Grid.instance.GetPlaceableFromVector(GetPosition() + new Vector3Int(0, 1, 0));
            if (above != null && !above.IsLiving())
            {
                above.Destroy();

                Grid.instance.ConnexeFall(above.GetPosition().x, above.GetPosition().y, above.GetPosition().z);
                //                GameManager.instance.ResetAllBatches();
            }
        }
    }
示例#2
0
    public void Use()
    {
        if (isDirectionFromPosition)
        {
            if (Launcher == Target)
            {
                Debug.Log("The hell, push caster is push target");
            }

            GetDirection();

            direction.Normalize();
            if (doesHeightCount)
            {
                direction.z = 0;
            }
        }
        //float angle = Mathf.Atan2(direction.y, direction.x); // we didive by the length of interval and round up
        //‎int hexakaidecan = (int) (angle / (22.5 * Mathf.Deg2Rad));
        Vector2Int delta    = CalculateDelta();
        int        distance = (int)nbCases;

        if (delta.x * delta.y != 0)                   // si les deux sont à 1
        {
            distance = (int)(nbCases / 1.4142 + 0.5); //Round up the euclidian distance
        }
        Placeable        directCollision    = null;
        List <Placeable> diagonalCollisions = new List <Placeable>();
        List <Vector3>   path = CheckPath(distance, delta, out directCollision, out diagonalCollisions);

        //Make damage and chek dodge conditions, destructions.... to modify according gameplay decided
        if (directCollision != null && directCollision.IsLiving())
        {
            EffectManager.instance.DirectAttack(new Damage((LivingPlaceable)directCollision, Launcher, damage));
        }
        foreach (Placeable diagcoll in diagonalCollisions)
        {
            if (diagcoll != null && diagcoll.IsLiving())
            {
                EffectManager.instance.DirectAttack(new Damage((LivingPlaceable)diagcoll, Launcher, damage));
            }
        }
        if (path.Count > 0)
        {
            Grid.instance.MoveBlock(Target, new Vector3Int((int)path[path.Count - 1].x, (int)path[path.Count - 1].y, (int)path[path.Count - 1].z), GameManager.instance.isServer);
            if (GameManager.instance.isClient)
            {
                GameManager.instance.RemoveBlockFromBatch(Target);
                //Could be either player, really...
                path.Insert(0, Target.GetPosition());
                // trigger visual effect and physics consequences
                Vector3 pos = Target.transform.position;
                GameManager.instance.PlayingPlaceable.gameObject.transform.LookAt(Target.transform);
                GameManager.instance.playingPlaceable.Player.StartMoveAlongBezier(path, Target, pushSpeed, false);
                Grid.instance.ConnexeFall((int)pos.x, (int)pos.y, (int)pos.z);
            }
        }


        //cmdMoveBlock(Target
    }